<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP, TupleSections, MultiWayIf, PatternSynonyms #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-comment">-- | Monadic type operations</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- This module contains monadic operations over types that contain mutable type</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- variables.</span><span>
</span><span id="line-15"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Utils.TcMType</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-16"></span><span>  </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier">TcTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier">TcKind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier">TcType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTauType"><span class="hs-identifier">TcTauType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier">TcThetaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyVarSet"><span class="hs-identifier">TcTyVarSet</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span>  </span><span class="hs-comment">--------------------------------</span><span>
</span><span id="line-19"></span><span>  </span><span class="hs-comment">-- Creating new mutable type variables</span><span>
</span><span id="line-20"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVar"><span class="hs-identifier">newFlexiTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newNamedFlexiTyVar"><span class="hs-identifier">newNamedFlexiTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier">newFlexiTyVarTy</span></a></span><span class="hs-special">,</span><span>              </span><span class="hs-comment">-- Kind -&gt; TcM TcType</span><span>
</span><span id="line-23"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTys"><span class="hs-identifier">newFlexiTyVarTys</span></a></span><span class="hs-special">,</span><span>             </span><span class="hs-comment">-- Int -&gt; Kind -&gt; TcM [TcType]</span><span>
</span><span id="line-24"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newOpenFlexiTyVarTy"><span class="hs-identifier">newOpenFlexiTyVarTy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newOpenTypeKind"><span class="hs-identifier">newOpenTypeKind</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVar"><span class="hs-identifier">newMetaKindVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVars"><span class="hs-identifier">newMetaKindVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier">newMetaTyVarTyAtLevel</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVar"><span class="hs-identifier">cloneMetaTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFmvTyVar"><span class="hs-identifier">newFmvTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFskTyVar"><span class="hs-identifier">newFskTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMultiplicityVar"><span class="hs-identifier">newMultiplicityVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier">readMetaTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier">writeMetaTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVarRef"><span class="hs-identifier">writeMetaTyVarRef</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newTauTvDetailsAtLevel"><span class="hs-identifier">newTauTvDetailsAtLevel</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier">newMetaDetails</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier">newMetaTyVarName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar_maybe"><span class="hs-identifier">isFilledMetaTyVar_maybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar"><span class="hs-identifier">isFilledMetaTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isUnfilledMetaTyVar"><span class="hs-identifier">isUnfilledMetaTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>
</span><span id="line-34"></span><span>  </span><span class="hs-comment">--------------------------------</span><span>
</span><span id="line-35"></span><span>  </span><span class="hs-comment">-- Creating new evidence variables</span><span>
</span><span id="line-36"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier">newEvVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newEvVars"><span class="hs-identifier">newEvVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newDict"><span class="hs-identifier">newDict</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWanted"><span class="hs-identifier">newWanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWanteds"><span class="hs-identifier">newWanteds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneWanted"><span class="hs-identifier">cloneWanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneWC"><span class="hs-identifier">cloneWC</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWanted"><span class="hs-identifier">emitWanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier">emitWantedEq</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVar"><span class="hs-identifier">emitWantedEvVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVars"><span class="hs-identifier">emitWantedEvVars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitDerivedEqs"><span class="hs-identifier">emitDerivedEqs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html#newTcEvBinds"><span class="hs-identifier">newTcEvBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html#newNoTcEvBinds"><span class="hs-identifier">newNoTcEvBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html#addTcEvBind"><span class="hs-identifier">addTcEvBind</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitNewExprHole"><span class="hs-identifier">emitNewExprHole</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newCoercionHole"><span class="hs-identifier">newCoercionHole</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#fillCoercionHole"><span class="hs-identifier">fillCoercionHole</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isFilledCoercionHole"><span class="hs-identifier">isFilledCoercionHole</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole"><span class="hs-identifier">unpackCoercionHole</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole_maybe"><span class="hs-identifier">unpackCoercionHole_maybe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkCoercionHole"><span class="hs-identifier">checkCoercionHole</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier">newImplication</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span>  </span><span class="hs-comment">--------------------------------</span><span>
</span><span id="line-50"></span><span>  </span><span class="hs-comment">-- Instantiation</span><span>
</span><span id="line-51"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVars"><span class="hs-identifier">newMetaTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier">newMetaTyVarX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarsX"><span class="hs-identifier">newMetaTyVarsX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyVarX"><span class="hs-identifier">newMetaTyVarTyVarX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newTyVarTyVar"><span class="hs-identifier">newTyVarTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneTyVarTyVar"><span class="hs-identifier">cloneTyVarTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newPatSigTyVar"><span class="hs-identifier">newPatSigTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newSkolemTyVar"><span class="hs-identifier">newSkolemTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWildCardX"><span class="hs-identifier">newWildCardX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span>  </span><span class="hs-comment">--------------------------------</span><span>
</span><span id="line-57"></span><span>  </span><span class="hs-comment">-- Expected types</span><span>
</span><span id="line-58"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier">ExpType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier">ExpSigmaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier">ExpRhoType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier">mkCheckExpType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newInferExpType"><span class="hs-identifier">newInferExpType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tcInfer"><span class="hs-identifier">tcInfer</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-60"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier">readExpType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readExpType_maybe"><span class="hs-identifier">readExpType_maybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readScaledExpType"><span class="hs-identifier">readScaledExpType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#expTypeToType"><span class="hs-identifier">expTypeToType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#scaledExpTypeToType"><span class="hs-identifier">scaledExpTypeToType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkingExpType_maybe"><span class="hs-identifier">checkingExpType_maybe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkingExpType"><span class="hs-identifier">checkingExpType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-63"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#inferResultToType"><span class="hs-identifier">inferResultToType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#fillInferResult"><span class="hs-identifier">fillInferResult</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTcType"><span class="hs-identifier">promoteTcType</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-64"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTyVar"><span class="hs-identifier">promoteTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier">promoteTyVarSet</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span>  </span><span class="hs-comment">--------------------------------</span><span>
</span><span id="line-67"></span><span>  </span><span class="hs-comment">-- Zonking and tidying</span><span>
</span><span id="line-68"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier">zonkTidyTcType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcTypes"><span class="hs-identifier">zonkTidyTcTypes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier">zonkTidyOrigin</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-69"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidyEvVar"><span class="hs-identifier">tidyEvVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidyCt"><span class="hs-identifier">tidyCt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidyHole"><span class="hs-identifier">tidyHole</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier">tidySkolemInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-70"></span><span>    </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier">zonkTcTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVars"><span class="hs-identifier">zonkTcTyVars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-71"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier">zonkTcTyVarToTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkInvisTVBinder"><span class="hs-identifier">zonkInvisTVBinder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-72"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFV"><span class="hs-identifier">zonkTyCoVarsAndFV</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypeAndFV"><span class="hs-identifier">zonkTcTypeAndFV</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkDTyCoVarSetAndFV"><span class="hs-identifier">zonkDTyCoVarSetAndFV</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-73"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFVList"><span class="hs-identifier">zonkTyCoVarsAndFVList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-74"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfType"><span class="hs-identifier">candidateQTyVarsOfType</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfKind"><span class="hs-identifier">candidateQTyVarsOfKind</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-75"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier">candidateQTyVarsOfTypes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfKinds"><span class="hs-identifier">candidateQTyVarsOfKinds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-76"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier">CandidatesQTvs</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#delCandidates"><span class="hs-identifier">delCandidates</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateKindVars"><span class="hs-identifier">candidateKindVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#partitionCandidates"><span class="hs-identifier">partitionCandidates</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-77"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkAndSkolemise"><span class="hs-identifier">zonkAndSkolemise</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#skolemiseQuantifiedTyVar"><span class="hs-identifier">skolemiseQuantifiedTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-78"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#defaultTyVar"><span class="hs-identifier">defaultTyVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#quantifyTyVars"><span class="hs-identifier">quantifyTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isQuantifiableTv"><span class="hs-identifier">isQuantifiableTv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-79"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier">zonkTcType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypes"><span class="hs-identifier">zonkTcTypes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCo"><span class="hs-identifier">zonkCo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-80"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier">zonkTyCoVarKind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKindBinder"><span class="hs-identifier">zonkTyCoVarKindBinder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkEvVar"><span class="hs-identifier">zonkEvVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkWC"><span class="hs-identifier">zonkWC</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkImplication"><span class="hs-identifier">zonkImplication</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkSimples"><span class="hs-identifier">zonkSimples</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-83"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkId"><span class="hs-identifier">zonkId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCoVar"><span class="hs-identifier">zonkCoVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-84"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier">zonkCt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier">zonkSkolemInfo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#skolemiseUnboundMetaTyVar"><span class="hs-identifier">skolemiseUnboundMetaTyVar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span>  </span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-89"></span><span>  </span><span class="hs-comment">-- Levity polymorphism</span><span>
</span><span id="line-90"></span><span>  </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#ensureNotLevPoly"><span class="hs-identifier">ensureNotLevPoly</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkForLevPoly"><span class="hs-identifier">checkForLevPoly</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkForLevPolyX"><span class="hs-identifier">checkForLevPolyX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#formatLevPolyErr"><span class="hs-identifier">formatLevPolyErr</span></a></span><span>
</span><span id="line-91"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-95"></span><span class="hs-comment">-- friends:</span><span>
</span><span id="line-96"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-97"></span><span>
</span><span id="line-98"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span>   </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html"><span class="hs-identifier">GHC.Tc.Utils.Unify</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier">unifyType</span></a></span><span> </span><span class="hs-comment">{- , unifyKind -}</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-101"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html"><span class="hs-identifier">GHC.Core.TyCo.Ppr</span></a></span><span>
</span><span id="line-102"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-103"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-104"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-105"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-107"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-108"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-109"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-comment">-- others:</span><span>
</span><span id="line-112"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>        </span><span class="hs-comment">-- TcType, amongst others</span><span>
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-114"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-115"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Id</span></span><span>
</span><span id="line-116"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-117"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-118"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>
</span><span id="line-119"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.Prim.html"><span class="hs-identifier">GHC.Builtin.Types.Prim</span></a></span><span>
</span><span id="line-120"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-121"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html"><span class="hs-identifier">GHC.Types.Name.Env</span></a></span><span>
</span><span id="line-122"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-123"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-124"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-125"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-126"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Pair.html"><span class="hs-identifier">GHC.Data.Pair</span></a></span><span>
</span><span id="line-127"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-128"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-129"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-130"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier">TypeOrKind</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-133"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-134"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#"><span class="hs-identifier">Control.Arrow</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#second"><span class="hs-identifier">second</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-135"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.Semigroup.html#"><span class="hs-identifier">Data.Semigroup</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Semi</span></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Kind variables
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVar"><span class="hs-identifier hs-type">newMetaKindVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span>
</span><span id="line-146"></span><span id="newMetaKindVar"><span class="annot"><span class="annottext">newMetaKindVar :: TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVar"><span class="hs-identifier hs-var hs-var">newMetaKindVar</span></a></span></span><span>
</span><span id="line-147"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078309"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681078309"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span>
</span><span id="line-148"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078307"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078307"><span class="hs-identifier hs-var">name</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-var">newMetaTyVarName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;k&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>                    </span><span class="hs-comment">-- All MetaKindVars are called &quot;k&quot;</span><span>
</span><span id="line-150"></span><span>                    </span><span class="hs-comment">-- They may be jiggled by tidying</span><span>
</span><span id="line-151"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078305"><span class="annot"><span class="annottext">kv :: TyVar
</span><a href="#local-6989586621681078305"><span class="hs-identifier hs-var hs-var">kv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078307"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681078309"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-152"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newMetaKindVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078305"><span class="hs-identifier hs-var">kv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-153"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078305"><span class="hs-identifier hs-var">kv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVars"><span class="hs-identifier hs-type">newMetaKindVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-156"></span><span id="newMetaKindVars"><span class="annot"><span class="annottext">newMetaKindVars :: Int -&gt; TcM [Kind]
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVars"><span class="hs-identifier hs-var hs-var">newMetaKindVars</span></a></span></span><span> </span><span id="local-6989586621681078299"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681078299"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcM Kind -&gt; TcM [Kind]
forall (m :: * -&gt; *) a. Applicative m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="../../base/src/Control.Monad.html#replicateM"><span class="hs-identifier hs-var">replicateM</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681078299"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaKindVar"><span class="hs-identifier hs-var">newMetaKindVar</span></a></span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
     Evidence variables; range over constraints we can abstract over
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-165"></span><span>
</span><span id="line-166"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newEvVars"><span class="hs-identifier hs-type">newEvVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-167"></span><span id="newEvVars"><span class="annot"><span class="annottext">newEvVars :: [Kind] -&gt; TcM [TyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVars"><span class="hs-identifier hs-var hs-var">newEvVars</span></a></span></span><span> </span><span id="local-6989586621681078296"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681078296"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar)
-&gt; [Kind] -&gt; TcM [TyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall gbl lcl. Kind -&gt; TcRnIf gbl lcl TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681078296"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span id="local-6989586621681079050"><span id="local-6989586621681079051"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-type">newEvVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRnIf"><span class="hs-identifier hs-type">TcRnIf</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681079051"><span class="hs-identifier hs-type">gbl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681079050"><span class="hs-identifier hs-type">lcl</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span></span></span><span>
</span><span id="line-172"></span><span class="hs-comment">-- Creates new *rigid* variables for predicates</span><span>
</span><span id="line-173"></span><span id="newEvVar"><span class="annot"><span class="annottext">newEvVar :: forall gbl lcl. Kind -&gt; TcRnIf gbl lcl TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var hs-var">newEvVar</span></a></span></span><span> </span><span id="local-6989586621681078291"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078291"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078290"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078290"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; TcRnIf gbl lcl Name
forall gbl lcl. OccName -&gt; TcRnIf gbl lcl Name
</span><a href="GHC.Tc.Utils.Monad.html#newSysName"><span class="hs-identifier hs-var">newSysName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; OccName
</span><a href="GHC.Tc.Utils.TcMType.html#predTypeOccName"><span class="hs-identifier hs-var">predTypeOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078291"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcRnIf gbl lcl TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Id.html#mkLocalIdOrCoVar"><span class="hs-identifier hs-var">mkLocalIdOrCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078290"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078291"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWanted"><span class="hs-identifier hs-type">newWanted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-177"></span><span class="hs-comment">-- Deals with both equality and non-equality predicates</span><span>
</span><span id="line-178"></span><span id="newWanted"><span class="annot"><span class="annottext">newWanted :: CtOrigin -&gt; Maybe TypeOrKind -&gt; Kind -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#newWanted"><span class="hs-identifier hs-var hs-var">newWanted</span></a></span></span><span> </span><span id="local-6989586621681078284"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078284"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681078283"><span class="annot"><span class="annottext">Maybe TypeOrKind
</span><a href="#local-6989586621681078283"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681078282"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078282"><span class="hs-identifier hs-var">pty</span></a></span></span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681078281"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078281"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078284"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
</span><a href="#local-6989586621681078283"><span class="hs-identifier hs-var">t_or_k</span></a></span><span>
</span><span id="line-180"></span><span>       </span><span id="local-6989586621681078279"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681078279"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isEqPrimPred"><span class="hs-identifier hs-var">isEqPrimPred</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078282"><span class="hs-identifier hs-var">pty</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-var">HoleDest</span></a></span><span>  </span><span class="annot"><span class="annottext">(CoercionHole -&gt; TcEvDest)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcEvDest
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
-&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
</span><a href="GHC.Tc.Utils.TcMType.html#newCoercionHole"><span class="hs-identifier hs-var">newCoercionHole</span></a></span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
</span><a href="GHC.Core.TyCo.Rep.html#YesBlockSubst"><span class="hs-identifier hs-var">YesBlockSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078282"><span class="hs-identifier hs-var">pty</span></a></span><span>
</span><span id="line-181"></span><span>                                </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#EvVarDest"><span class="hs-identifier hs-var">EvVarDest</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcEvDest)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcEvDest
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall gbl lcl. Kind -&gt; TcRnIf gbl lcl TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078282"><span class="hs-identifier hs-var">pty</span></a></span><span>
</span><span id="line-182"></span><span>       </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(CtEvidence -&gt; TcM CtEvidence) -&gt; CtEvidence -&gt; TcM CtEvidence
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtWanted :: Kind -&gt; TcEvDest -&gt; ShadowInfo -&gt; CtLoc -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681078279"><span class="hs-identifier hs-var">d</span></a></span><span>
</span><span id="line-183"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078282"><span class="hs-identifier hs-var">pty</span></a></span><span>
</span><span id="line-184"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_nosh :: ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#ctev_nosh"><span class="hs-identifier hs-var">ctev_nosh</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#WDeriv"><span class="hs-identifier hs-var">WDeriv</span></a></span><span>
</span><span id="line-185"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078281"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWanteds"><span class="hs-identifier hs-type">newWanteds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-188"></span><span id="newWanteds"><span class="annot"><span class="annottext">newWanteds :: CtOrigin -&gt; [Kind] -&gt; TcM [CtEvidence]
</span><a href="GHC.Tc.Utils.TcMType.html#newWanteds"><span class="hs-identifier hs-var hs-var">newWanteds</span></a></span></span><span> </span><span id="local-6989586621681078266"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078266"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; TcM CtEvidence) -&gt; [Kind] -&gt; TcM [CtEvidence]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; Kind -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#newWanted"><span class="hs-identifier hs-var">newWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078266"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-189"></span><span>
</span><span id="line-190"></span><span class="hs-comment">----------------------------------------------</span><span>
</span><span id="line-191"></span><span class="hs-comment">-- Cloning constraints</span><span>
</span><span id="line-192"></span><span class="hs-comment">----------------------------------------------</span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneWanted"><span class="hs-identifier hs-type">cloneWanted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span>
</span><span id="line-195"></span><span id="cloneWanted"><span class="annot"><span class="annottext">cloneWanted :: Ct -&gt; TcM Ct
</span><a href="GHC.Tc.Utils.TcMType.html#cloneWanted"><span class="hs-identifier hs-var hs-var">cloneWanted</span></a></span></span><span> </span><span id="local-6989586621681078265"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681078265"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-196"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681078264"><span class="annot"><span class="annottext">ev :: CtEvidence
</span><a href="#local-6989586621681078264"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-type">HoleDest</span></a></span><span> </span><span id="local-6989586621681078263"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078263"><span class="hs-identifier hs-var">old_hole</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: CtEvidence -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078262"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078262"><span class="hs-identifier hs-var">pty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#ctEvidence"><span class="hs-identifier hs-var">ctEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681078265"><span class="hs-identifier hs-var">ct</span></a></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078260"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078260"><span class="hs-identifier hs-var">co_hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
-&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
</span><a href="GHC.Tc.Utils.TcMType.html#newCoercionHole"><span class="hs-identifier hs-var">newCoercionHole</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionHole -&gt; BlockSubstFlag
</span><a href="GHC.Core.TyCo.Rep.html#ch_blocker"><span class="hs-identifier hs-var hs-var">ch_blocker</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078263"><span class="hs-identifier hs-var">old_hole</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078262"><span class="hs-identifier hs-var">pty</span></a></span><span>
</span><span id="line-198"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681078264"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-var">HoleDest</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078260"><span class="hs-identifier hs-var">co_hole</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-199"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-200"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681078265"><span class="hs-identifier hs-var">ct</span></a></span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneWC"><span class="hs-identifier hs-type">cloneWC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-203"></span><span class="hs-comment">-- Clone all the evidence bindings in</span><span>
</span><span id="line-204"></span><span class="hs-comment">--   a) the ic_bind field of any implications</span><span>
</span><span id="line-205"></span><span class="hs-comment">--   b) the CoercionHoles of any wanted constraints</span><span>
</span><span id="line-206"></span><span class="hs-comment">-- so that solving the WantedConstraints will not have any visible side</span><span>
</span><span id="line-207"></span><span class="hs-comment">-- effect, /except/ from causing unifications</span><span>
</span><span id="line-208"></span><span id="cloneWC"><span class="annot"><span class="annottext">cloneWC :: WantedConstraints -&gt; TcM WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#cloneWC"><span class="hs-identifier hs-var hs-var">cloneWC</span></a></span></span><span> </span><span id="local-6989586621681078257"><span class="annot"><span class="annottext">wc :: WantedConstraints
</span><a href="#local-6989586621681078257"><span class="hs-identifier hs-var">wc</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Bag Ct
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078254"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681078254"><span class="hs-identifier hs-var">simples</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078252"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681078252"><span class="hs-identifier hs-var">implics</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078251"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681078251"><span class="hs-identifier hs-var">simples'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcM Ct) -&gt; Bag Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Ct)
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
</span><a href="GHC.Tc.Utils.TcMType.html#cloneWanted"><span class="hs-identifier hs-var">cloneWanted</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681078254"><span class="hs-identifier hs-var">simples</span></a></span><span>
</span><span id="line-210"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078249"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681078249"><span class="hs-identifier hs-var">implics'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication)
-&gt; Bag Implication
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Implication)
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
</span><a href="GHC.Tc.Utils.TcMType.html#cloneImplication"><span class="hs-identifier hs-var">cloneImplication</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681078252"><span class="hs-identifier hs-var">implics</span></a></span><span>
</span><span id="line-211"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681078257"><span class="hs-identifier hs-var">wc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Bag Ct
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681078251"><span class="hs-identifier hs-var">simples'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681078249"><span class="hs-identifier hs-var">implics'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-212"></span><span>
</span><span id="line-213"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneImplication"><span class="hs-identifier hs-type">cloneImplication</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>
</span><span id="line-214"></span><span id="cloneImplication"><span class="annot"><span class="annottext">cloneImplication :: Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
</span><a href="GHC.Tc.Utils.TcMType.html#cloneImplication"><span class="hs-identifier hs-var hs-var">cloneImplication</span></a></span></span><span> </span><span id="local-6989586621681078247"><span class="annot"><span class="annottext">implic :: Implication
</span><a href="#local-6989586621681078247"><span class="hs-identifier hs-var">implic</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_binds :: Implication -&gt; EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078244"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681078244"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078242"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681078242"><span class="hs-identifier hs-var">inner_wanted</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-215"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078241"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681078241"><span class="hs-identifier hs-var">binds'</span></a></span></span><span>        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#cloneEvBindsVar"><span class="hs-identifier hs-var">cloneEvBindsVar</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681078244"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-216"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078239"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681078239"><span class="hs-identifier hs-var">inner_wanted'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#cloneWC"><span class="hs-identifier hs-var">cloneWC</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681078242"><span class="hs-identifier hs-var">inner_wanted</span></a></span><span>
</span><span id="line-217"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681078247"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681078241"><span class="hs-identifier hs-var">binds'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681078239"><span class="hs-identifier hs-var">inner_wanted'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span class="hs-comment">----------------------------------------------</span><span>
</span><span id="line-220"></span><span class="hs-comment">-- Emitting constraints</span><span>
</span><span id="line-221"></span><span class="hs-comment">----------------------------------------------</span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span class="hs-comment">-- | Emits a new Wanted. Deals with both equalities and non-equalities.</span><span>
</span><span id="line-224"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWanted"><span class="hs-identifier hs-type">emitWanted</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvTerm"><span class="hs-identifier hs-type">EvTerm</span></a></span><span>
</span><span id="line-225"></span><span id="emitWanted"><span class="annot"><span class="annottext">emitWanted :: CtOrigin -&gt; Kind -&gt; TcM EvTerm
</span><a href="GHC.Tc.Utils.TcMType.html#emitWanted"><span class="hs-identifier hs-var hs-var">emitWanted</span></a></span></span><span> </span><span id="local-6989586621681078238"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078238"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681078237"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078237"><span class="hs-identifier hs-var">pty</span></a></span></span><span>
</span><span id="line-226"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078236"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681078236"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; Kind -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#newWanted"><span class="hs-identifier hs-var">newWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078238"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078237"><span class="hs-identifier hs-var">pty</span></a></span><span>
</span><span id="line-227"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitSimple"><span class="hs-identifier hs-var">emitSimple</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcRn ()) -&gt; Ct -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681078236"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-228"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">EvTerm -&gt; TcM EvTerm
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(EvTerm -&gt; TcM EvTerm) -&gt; EvTerm -&gt; TcM EvTerm
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; EvTerm
</span><a href="GHC.Tc.Types.Constraint.html#ctEvTerm"><span class="hs-identifier hs-var">ctEvTerm</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681078236"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitDerivedEqs"><span class="hs-identifier hs-type">emitDerivedEqs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- Emit some new derived nominal equalities</span><span>
</span><span id="line-232"></span><span id="emitDerivedEqs"><span class="annot"><span class="annottext">emitDerivedEqs :: CtOrigin -&gt; [(Kind, Kind)] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#emitDerivedEqs"><span class="hs-identifier hs-var hs-var">emitDerivedEqs</span></a></span></span><span> </span><span id="local-6989586621681078233"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078233"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681078232"><span class="annot"><span class="annottext">[(Kind, Kind)]
</span><a href="#local-6989586621681078232"><span class="hs-identifier hs-var">pairs</span></a></span></span><span>
</span><span id="line-233"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[(Kind, Kind)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[(Kind, Kind)]
</span><a href="#local-6989586621681078232"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-234"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-235"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-236"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078230"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078230"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078233"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-237"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bag Ct -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitSimples"><span class="hs-identifier hs-var">emitSimples</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Ct] -&gt; Bag Ct
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Kind, Kind) -&gt; Ct) -&gt; [(Kind, Kind)] -&gt; [Ct]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; (Kind, Kind) -&gt; Ct
</span><a href="#local-6989586621681078227"><span class="hs-identifier hs-var">mk_one</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078230"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Kind, Kind)]
</span><a href="#local-6989586621681078232"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-238"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-239"></span><span>    </span><span id="local-6989586621681078227"><span class="annot"><span class="annottext">mk_one :: CtLoc -&gt; (Kind, Kind) -&gt; Ct
</span><a href="#local-6989586621681078227"><span class="hs-identifier hs-var hs-var">mk_one</span></a></span></span><span> </span><span id="local-6989586621681078226"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078226"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681078225"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078225"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681078224"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078224"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-240"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">(CtEvidence -&gt; Ct) -&gt; CtEvidence -&gt; Ct
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-241"></span><span>         </span><span class="annot"><span class="annottext">CtDerived :: Kind -&gt; CtLoc -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#CtDerived"><span class="hs-identifier hs-type">CtDerived</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.Coercion.html#mkPrimEqPred"><span class="hs-identifier hs-var">mkPrimEqPred</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078225"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078224"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-242"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078226"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-243"></span><span>
</span><span id="line-244"></span><span class="hs-comment">-- | Emits a new equality constraint</span><span>
</span><span id="line-245"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier hs-type">emitWantedEq</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-246"></span><span id="emitWantedEq"><span class="annot"><span class="annottext">emitWantedEq :: CtOrigin -&gt; TypeOrKind -&gt; Role -&gt; Kind -&gt; Kind -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier hs-var hs-var">emitWantedEq</span></a></span></span><span> </span><span id="local-6989586621681078221"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078221"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681078220"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681078220"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681078219"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681078219"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span id="local-6989586621681078218"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078218"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681078217"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078217"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-247"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078216"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078216"><span class="hs-identifier hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
-&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
</span><a href="GHC.Tc.Utils.TcMType.html#newCoercionHole"><span class="hs-identifier hs-var">newCoercionHole</span></a></span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
</span><a href="GHC.Core.TyCo.Rep.html#YesBlockSubst"><span class="hs-identifier hs-var">YesBlockSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078215"><span class="hs-identifier hs-var">pty</span></a></span><span>
</span><span id="line-248"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078214"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078214"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078221"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; Maybe TypeOrKind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681078220"><span class="hs-identifier hs-var">t_or_k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-249"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitSimple"><span class="hs-identifier hs-var">emitSimple</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcRn ()) -&gt; Ct -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">(CtEvidence -&gt; Ct) -&gt; CtEvidence -&gt; Ct
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-250"></span><span>         </span><span class="annot"><span class="annottext">CtWanted :: Kind -&gt; TcEvDest -&gt; ShadowInfo -&gt; CtLoc -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078215"><span class="hs-identifier hs-var">pty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-var">HoleDest</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078216"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-251"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_nosh :: ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#ctev_nosh"><span class="hs-identifier hs-var">ctev_nosh</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#WDeriv"><span class="hs-identifier hs-var">WDeriv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078214"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-252"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionHole -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#HoleCo"><span class="hs-identifier hs-var">HoleCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078216"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-253"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-254"></span><span>    </span><span id="local-6989586621681078215"><span class="annot"><span class="annottext">pty :: Kind
</span><a href="#local-6989586621681078215"><span class="hs-identifier hs-var hs-var">pty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; Kind -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.Coercion.html#mkPrimEqPredRole"><span class="hs-identifier hs-var">mkPrimEqPredRole</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681078219"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078218"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078217"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-255"></span><span>
</span><span id="line-256"></span><span class="hs-comment">-- | Creates a new EvVar and immediately emits it as a Wanted.</span><span>
</span><span id="line-257"></span><span class="hs-comment">-- No equality predicates here.</span><span>
</span><span id="line-258"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVar"><span class="hs-identifier hs-type">emitWantedEvVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span>
</span><span id="line-259"></span><span id="emitWantedEvVar"><span class="annot"><span class="annottext">emitWantedEvVar :: CtOrigin -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVar"><span class="hs-identifier hs-var hs-var">emitWantedEvVar</span></a></span></span><span> </span><span id="local-6989586621681078211"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078211"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681078210"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078210"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-260"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078209"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078209"><span class="hs-identifier hs-var">new_cv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall gbl lcl. Kind -&gt; TcRnIf gbl lcl TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078210"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-261"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078208"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078208"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078211"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-262"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078207"><span class="annot"><span class="annottext">ctev :: CtEvidence
</span><a href="#local-6989586621681078207"><span class="hs-identifier hs-var hs-var">ctev</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtWanted :: Kind -&gt; TcEvDest -&gt; ShadowInfo -&gt; CtLoc -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#EvVarDest"><span class="hs-identifier hs-var">EvVarDest</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078209"><span class="hs-identifier hs-var">new_cv</span></a></span><span>
</span><span id="line-263"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078210"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-264"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_nosh :: ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#ctev_nosh"><span class="hs-identifier hs-var">ctev_nosh</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShadowInfo
</span><a href="GHC.Tc.Types.Constraint.html#WDeriv"><span class="hs-identifier hs-var">WDeriv</span></a></span><span>
</span><span id="line-265"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_loc :: CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#ctev_loc"><span class="hs-identifier hs-var">ctev_loc</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078208"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-266"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitSimple"><span class="hs-identifier hs-var">emitSimple</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcRn ()) -&gt; Ct -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681078207"><span class="hs-identifier hs-var">ctev</span></a></span><span>
</span><span id="line-267"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078209"><span class="hs-identifier hs-var">new_cv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVars"><span class="hs-identifier hs-type">emitWantedEvVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-270"></span><span id="emitWantedEvVars"><span class="annot"><span class="annottext">emitWantedEvVars :: CtOrigin -&gt; [Kind] -&gt; TcM [TyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVars"><span class="hs-identifier hs-var hs-var">emitWantedEvVars</span></a></span></span><span> </span><span id="local-6989586621681078206"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078206"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar)
-&gt; [Kind] -&gt; TcM [TyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtOrigin -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEvVar"><span class="hs-identifier hs-var">emitWantedEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078206"><span class="hs-identifier hs-var">orig</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-271"></span><span>
</span><span id="line-272"></span><span class="hs-comment">-- | Emit a new wanted expression hole</span><span>
</span><span id="line-273"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#emitNewExprHole"><span class="hs-identifier hs-type">emitNewExprHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span>   </span><span class="hs-comment">-- of the hole</span><span>
</span><span id="line-274"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>        </span><span class="hs-comment">-- of the evidence</span><span>
</span><span id="line-275"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span id="emitNewExprHole"><span class="annot"><span class="annottext">emitNewExprHole :: OccName -&gt; TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#emitNewExprHole"><span class="hs-identifier hs-var hs-var">emitNewExprHole</span></a></span></span><span> </span><span id="local-6989586621681078203"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681078203"><span class="hs-identifier hs-var">occ</span></a></span></span><span> </span><span id="local-6989586621681078202"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078202"><span class="hs-identifier hs-var">ev_id</span></a></span></span><span> </span><span id="local-6989586621681078201"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078201"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-277"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078200"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078200"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#ExprHoleOrigin"><span class="hs-identifier hs-var">ExprHoleOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681078203"><span class="hs-identifier hs-var">occ</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; Maybe TypeOrKind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078195"><span class="annot"><span class="annottext">hole :: Hole
</span><a href="#local-6989586621681078195"><span class="hs-identifier hs-var hs-var">hole</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Hole :: HoleSort -&gt; OccName -&gt; Kind -&gt; CtLoc -&gt; Hole
</span><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_sort :: HoleSort
</span><a href="GHC.Tc.Types.Constraint.html#hole_sort"><span class="hs-identifier hs-var">hole_sort</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; HoleSort
</span><a href="GHC.Tc.Types.Constraint.html#ExprHole"><span class="hs-identifier hs-var">ExprHole</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078202"><span class="hs-identifier hs-var">ev_id</span></a></span><span>
</span><span id="line-279"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hole_occ :: OccName
</span><a href="GHC.Tc.Types.Constraint.html#hole_occ"><span class="hs-identifier hs-var">hole_occ</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078202"><span class="hs-identifier hs-var">ev_id</span></a></span><span>
</span><span id="line-280"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078201"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-281"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hole_loc :: CtLoc
</span><a href="GHC.Tc.Types.Constraint.html#hole_loc"><span class="hs-identifier hs-var">hole_loc</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681078200"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-282"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Hole -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitHole"><span class="hs-identifier hs-var">emitHole</span></a></span><span> </span><span class="annot"><span class="annottext">Hole
</span><a href="#local-6989586621681078195"><span class="hs-identifier hs-var">hole</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newDict"><span class="hs-identifier hs-type">newDict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DictId"><span class="hs-identifier hs-type">DictId</span></a></span><span>
</span><span id="line-285"></span><span id="newDict"><span class="annot"><span class="annottext">newDict :: Class -&gt; [Kind] -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newDict"><span class="hs-identifier hs-var hs-var">newDict</span></a></span></span><span> </span><span id="local-6989586621681078185"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681078185"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681078184"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681078184"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-286"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078183"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078183"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; TcM Name
forall gbl lcl. OccName -&gt; TcRnIf gbl lcl Name
</span><a href="GHC.Tc.Utils.Monad.html#newSysName"><span class="hs-identifier hs-var">newSysName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkDictOcc"><span class="hs-identifier hs-var">mkDictOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681078185"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-287"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; Kind -&gt; Kind -&gt; TyVar
Name -&gt; Kind -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Id.html#mkLocalId"><span class="hs-identifier hs-var">mkLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078183"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [Kind] -&gt; Kind
</span><a href="GHC.Core.Predicate.html#mkClassPred"><span class="hs-identifier hs-var">mkClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681078185"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681078184"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-288"></span><span>
</span><span id="line-289"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#predTypeOccName"><span class="hs-identifier hs-type">predTypeOccName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#OccName"><span class="hs-identifier hs-type">OccName</span></a></span><span>
</span><span id="line-290"></span><span id="predTypeOccName"><span class="annot"><span class="annottext">predTypeOccName :: Kind -&gt; OccName
</span><a href="GHC.Tc.Utils.TcMType.html#predTypeOccName"><span class="hs-identifier hs-var hs-var">predTypeOccName</span></a></span></span><span> </span><span id="local-6989586621681078179"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078179"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078179"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-291"></span><span>    </span><span class="annot"><a href="GHC.Core.Predicate.html#ClassPred"><span class="hs-identifier hs-type">ClassPred</span></a></span><span> </span><span id="local-6989586621681078176"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681078176"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkDictOcc"><span class="hs-identifier hs-var">mkDictOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681078176"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-292"></span><span>    </span><span class="annot"><a href="GHC.Core.Predicate.html#EqPred"><span class="hs-identifier hs-type">EqPred</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkVarOccFS"><span class="hs-identifier hs-var">mkVarOccFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;co&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>    </span><span class="annot"><a href="GHC.Core.Predicate.html#IrredPred"><span class="hs-identifier hs-type">IrredPred</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkVarOccFS"><span class="hs-identifier hs-var">mkVarOccFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;irred&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>    </span><span class="annot"><a href="GHC.Core.Predicate.html#ForAllPred"><span class="hs-identifier hs-type">ForAllPred</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkVarOccFS"><span class="hs-identifier hs-var">mkVarOccFS</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;df&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-295"></span><span>
</span><span id="line-296"></span><span class="hs-comment">-- | Create a new 'Implication' with as many sensible defaults for its fields</span><span>
</span><span id="line-297"></span><span class="hs-comment">-- as possible. Note that the 'ic_tclvl', 'ic_binds', and 'ic_info' fields do</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- /not/ have sensible defaults, so they are initialized with lazy thunks that</span><span>
</span><span id="line-299"></span><span class="hs-comment">-- will 'panic' if forced, so one should take care to initialize these fields</span><span>
</span><span id="line-300"></span><span class="hs-comment">-- after creation.</span><span>
</span><span id="line-301"></span><span class="hs-comment">--</span><span>
</span><span id="line-302"></span><span class="hs-comment">-- This is monadic to look up the 'TcLclEnv', which is used to initialize</span><span>
</span><span id="line-303"></span><span class="hs-comment">-- 'ic_env', and to set the -Winaccessible-code flag. See</span><span>
</span><span id="line-304"></span><span class="hs-comment">-- Note [Avoid -Winaccessible-code when deriving] in &quot;GHC.Tc.TyCl.Instance&quot;.</span><span>
</span><span id="line-305"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-type">newImplication</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>
</span><span id="line-306"></span><span id="newImplication"><span class="annot"><span class="annottext">newImplication :: IOEnv (Env TcGblEnv TcLclEnv) Implication
</span><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-var hs-var">newImplication</span></a></span></span><span>
</span><span id="line-307"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681078171"><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681078171"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcLclEnv
forall gbl lcl. TcRnIf gbl lcl lcl
</span><a href="GHC.Tc.Utils.Monad.html#getLclEnv"><span class="hs-identifier hs-var">getLclEnv</span></a></span><span>
</span><span id="line-308"></span><span>       </span><span id="local-6989586621681078169"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681078169"><span class="hs-identifier hs-var">warn_inaccessible</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. WarningFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#woptM"><span class="hs-identifier hs-var">woptM</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnInaccessibleCode"><span class="hs-identifier hs-var">Opt_WarnInaccessibleCode</span></a></span><span>
</span><span id="line-309"></span><span>       </span><span class="annot"><span class="annottext">Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="GHC.Tc.Types.Constraint.html#implicationPrototype"><span class="hs-identifier hs-var">implicationPrototype</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_env :: TcLclEnv
</span><a href="GHC.Tc.Types.Constraint.html#ic_env"><span class="hs-identifier hs-var">ic_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLclEnv
</span><a href="#local-6989586621681078171"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-310"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_warn_inaccessible :: Bool
</span><a href="GHC.Tc.Types.Constraint.html#ic_warn_inaccessible"><span class="hs-identifier hs-var">ic_warn_inaccessible</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681078169"><span class="hs-identifier hs-var">warn_inaccessible</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-311"></span><span>
</span><span id="line-312"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Coercion holes
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-319"></span><span>
</span><span id="line-320"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newCoercionHole"><span class="hs-identifier hs-type">newCoercionHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#BlockSubstFlag"><span class="hs-identifier hs-type">BlockSubstFlag</span></a></span><span>  </span><span class="hs-comment">-- should the presence of this hole block substitution?</span><span>
</span><span id="line-321"></span><span>                                   </span><span class="hs-comment">-- See sub-wrinkle in TcCanonical</span><span>
</span><span id="line-322"></span><span>                                   </span><span class="hs-comment">-- Note [Equalities with incompatible kinds]</span><span>
</span><span id="line-323"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span>
</span><span id="line-324"></span><span id="newCoercionHole"><span class="annot"><span class="annottext">newCoercionHole :: BlockSubstFlag
-&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
</span><a href="GHC.Tc.Utils.TcMType.html#newCoercionHole"><span class="hs-identifier hs-var hs-var">newCoercionHole</span></a></span></span><span> </span><span id="local-6989586621681078163"><span class="annot"><span class="annottext">BlockSubstFlag
</span><a href="#local-6989586621681078163"><span class="hs-identifier hs-var">blocker</span></a></span></span><span> </span><span id="local-6989586621681078162"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078162"><span class="hs-identifier hs-var">pred_ty</span></a></span></span><span>
</span><span id="line-325"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078161"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078161"><span class="hs-identifier hs-var">co_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall gbl lcl. Kind -&gt; TcRnIf gbl lcl TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078162"><span class="hs-identifier hs-var">pred_ty</span></a></span><span>
</span><span id="line-326"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;New coercion hole:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078161"><span class="hs-identifier hs-var">co_var</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
</span><a href="#local-6989586621681078163"><span class="hs-identifier hs-var">blocker</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-327"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078159"><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078159"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Coercion
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (IORef (Maybe Coercion))
forall a env. a -&gt; IOEnv env (IORef a)
</span><a href="GHC.Data.IOEnv.html#newMutVar"><span class="hs-identifier hs-var">newMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Coercion
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-328"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(CoercionHole -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole)
-&gt; CoercionHole -&gt; IOEnv (Env TcGblEnv TcLclEnv) CoercionHole
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole :: TyVar -&gt; BlockSubstFlag -&gt; IORef (Maybe Coercion) -&gt; CoercionHole
</span><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_co_var :: TyVar
</span><a href="GHC.Core.TyCo.Rep.html#ch_co_var"><span class="hs-identifier hs-var">ch_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078161"><span class="hs-identifier hs-var">co_var</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ch_blocker :: BlockSubstFlag
</span><a href="GHC.Core.TyCo.Rep.html#ch_blocker"><span class="hs-identifier hs-var">ch_blocker</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockSubstFlag
</span><a href="#local-6989586621681078163"><span class="hs-identifier hs-var">blocker</span></a></span><span>
</span><span id="line-329"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ch_ref :: IORef (Maybe Coercion)
</span><a href="GHC.Core.TyCo.Rep.html#ch_ref"><span class="hs-identifier hs-var">ch_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078159"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-330"></span><span>
</span><span id="line-331"></span><span class="hs-comment">-- | Put a value in a coercion hole</span><span>
</span><span id="line-332"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#fillCoercionHole"><span class="hs-identifier hs-type">fillCoercionHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-333"></span><span id="fillCoercionHole"><span class="annot"><span class="annottext">fillCoercionHole :: CoercionHole -&gt; Coercion -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#fillCoercionHole"><span class="hs-identifier hs-var hs-var">fillCoercionHole</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_ref :: CoercionHole -&gt; IORef (Maybe Coercion)
</span><a href="GHC.Core.TyCo.Rep.html#ch_ref"><span class="hs-identifier hs-var">ch_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078154"><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078154"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ch_co_var :: CoercionHole -&gt; TyVar
</span><a href="GHC.Core.TyCo.Rep.html#ch_co_var"><span class="hs-identifier hs-var">ch_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078153"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078153"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681078152"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078152"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-334"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span class="hs-cpp">
#if defined(DEBUG)
</span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">cts</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">readTcRef</span><span> </span><span class="hs-identifier">ref</span><span>
</span><span id="line-337"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">whenIsJust</span><span> </span><span class="hs-identifier">cts</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">old_co</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-338"></span><span>         </span><span class="hs-identifier">pprPanic</span><span> </span><span class="hs-string">&quot;Filling a filled coercion hole&quot;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cv</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">co</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">old_co</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Filling coercion hole&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078153"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078152"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-341"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion) -&gt; Maybe Coercion -&gt; TcRn ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">writeTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078154"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Maybe Coercion
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078152"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-342"></span><span>
</span><span id="line-343"></span><span class="hs-comment">-- | Is a coercion hole filled in?</span><span>
</span><span id="line-344"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isFilledCoercionHole"><span class="hs-identifier hs-type">isFilledCoercionHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-345"></span><span id="isFilledCoercionHole"><span class="annot"><span class="annottext">isFilledCoercionHole :: CoercionHole -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#isFilledCoercionHole"><span class="hs-identifier hs-var hs-var">isFilledCoercionHole</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_ref :: CoercionHole -&gt; IORef (Maybe Coercion)
</span><a href="GHC.Core.TyCo.Rep.html#ch_ref"><span class="hs-identifier hs-var">ch_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078149"><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078149"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Coercion -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Coercion -&gt; Bool)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
-&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078149"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span class="hs-comment">-- | Retrieve the contents of a coercion hole. Panics if the hole</span><span>
</span><span id="line-348"></span><span class="hs-comment">-- is unfilled</span><span>
</span><span id="line-349"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole"><span class="hs-identifier hs-type">unpackCoercionHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-350"></span><span id="unpackCoercionHole"><span class="annot"><span class="annottext">unpackCoercionHole :: CoercionHole -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole"><span class="hs-identifier hs-var hs-var">unpackCoercionHole</span></a></span></span><span> </span><span id="local-6989586621681078146"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078146"><span class="hs-identifier hs-var">hole</span></a></span></span><span>
</span><span id="line-351"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078145"><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="#local-6989586621681078145"><span class="hs-identifier hs-var">contents</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
</span><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole_maybe"><span class="hs-identifier hs-var">unpackCoercionHole_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078146"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-352"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="#local-6989586621681078145"><span class="hs-identifier hs-var">contents</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-353"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681078144"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078144"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078144"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-354"></span><span>           </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM Coercion
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unfilled coercion hole&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionHole -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681078146"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-355"></span><span>
</span><span id="line-356"></span><span class="hs-comment">-- | Retrieve the contents of a coercion hole, if it is filled</span><span>
</span><span id="line-357"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole_maybe"><span class="hs-identifier hs-type">unpackCoercionHole_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-358"></span><span id="unpackCoercionHole_maybe"><span class="annot"><span class="annottext">unpackCoercionHole_maybe :: CoercionHole -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
</span><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole_maybe"><span class="hs-identifier hs-var hs-var">unpackCoercionHole_maybe</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_ref :: CoercionHole -&gt; IORef (Maybe Coercion)
</span><a href="GHC.Core.TyCo.Rep.html#ch_ref"><span class="hs-identifier hs-var">ch_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078142"><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078142"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681078142"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-comment">-- | Check that a coercion is appropriate for filling a hole. (The hole</span><span>
</span><span id="line-361"></span><span class="hs-comment">-- itself is needed only for printing.</span><span>
</span><span id="line-362"></span><span class="hs-comment">-- Always returns the checked coercion, but this return value is necessary</span><span>
</span><span id="line-363"></span><span class="hs-comment">-- so that the input coercion is forced only when the output is forced.</span><span>
</span><span id="line-364"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkCoercionHole"><span class="hs-identifier hs-type">checkCoercionHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-365"></span><span id="checkCoercionHole"><span class="annot"><span class="annottext">checkCoercionHole :: TyVar -&gt; Coercion -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#checkCoercionHole"><span class="hs-identifier hs-var hs-var">checkCoercionHole</span></a></span></span><span> </span><span id="local-6989586621681078140"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078140"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span id="local-6989586621681078139"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078139"><span class="hs-identifier hs-var">co</span></a></span></span><span>
</span><span id="line-366"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span>
</span><span id="line-367"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078137"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078137"><span class="hs-identifier hs-var">cv_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#varType"><span class="hs-identifier hs-var hs-var">varType</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078140"><span class="hs-identifier hs-var">cv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-368"></span><span>                  </span><span class="hs-comment">-- co is already zonked, but cv might not be</span><span>
</span><span id="line-369"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-370"></span><span>         </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">ok</span><span> </span><span class="hs-identifier">cv_ty</span><span>
</span><span id="line-371"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Bad coercion hole&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span>
</span><span id="line-372"></span><span>                   </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cv</span><span> </span><span class="hs-operator">&lt;&gt;</span><span> </span><span class="hs-identifier">colon</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">vcat</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">t1</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">t2</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-keyword">role</span><span>
</span><span id="line-373"></span><span>                                            </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cv_ty</span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-374"></span><span>         </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078139"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-375"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-376"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078139"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-377"></span><span>
</span><span id="line-378"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-379"></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.Pair.html#Pair"><span class="hs-identifier hs-type">Pair</span></a></span><span> </span><span id="local-6989586621681078128"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078128"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681078127"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078127"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681078126"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681078126"><span class="hs-keyword hs-var">role</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; (Pair Kind, Role)
</span><a href="GHC.Core.Coercion.html#coercionKindRole"><span class="hs-identifier hs-var">coercionKindRole</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078139"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-380"></span><span>    </span><span id="local-6989586621681078133"><span class="annot"><span class="annottext">ok :: Kind -&gt; Bool
</span><a href="#local-6989586621681078133"><span class="hs-identifier hs-var hs-var">ok</span></a></span></span><span> </span><span id="local-6989586621681078121"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078121"><span class="hs-identifier hs-var">cv_ty</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#EqPred"><span class="hs-identifier hs-type">EqPred</span></a></span><span> </span><span id="local-6989586621681078120"><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681078120"><span class="hs-identifier hs-var">cv_rel</span></a></span></span><span> </span><span id="local-6989586621681078119"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078119"><span class="hs-identifier hs-var">cv_t1</span></a></span></span><span> </span><span id="local-6989586621681078118"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078118"><span class="hs-identifier hs-var">cv_t2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Pred
</span><a href="GHC.Core.Predicate.html#classifyPredType"><span class="hs-identifier hs-var">classifyPredType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078121"><span class="hs-identifier hs-var">cv_ty</span></a></span><span>
</span><span id="line-381"></span><span>             </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078128"><span class="hs-identifier hs-var">t1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Kind -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078119"><span class="hs-identifier hs-var">cv_t1</span></a></span><span>
</span><span id="line-382"></span><span>             </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078127"><span class="hs-identifier hs-var">t2</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Kind -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-operator hs-var">`eqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078118"><span class="hs-identifier hs-var">cv_t2</span></a></span><span>
</span><span id="line-383"></span><span>             </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681078126"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Role -&gt; Role -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">EqRel -&gt; Role
</span><a href="GHC.Core.Predicate.html#eqRelRole"><span class="hs-identifier hs-var">eqRelRole</span></a></span><span> </span><span class="annot"><span class="annottext">EqRel
</span><a href="#local-6989586621681078120"><span class="hs-identifier hs-var">cv_rel</span></a></span><span>
</span><span id="line-384"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-385"></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span class="hs-comment">{- **********************************************************************
*
                      ExpType functions
*
********************************************************************** -}</span><span>
</span><span id="line-392"></span><span>
</span><span id="line-393"></span><span class="hs-comment">{- Note [ExpType]
~~~~~~~~~~~~~~~~~
An ExpType is used as the &quot;expected type&quot; when type-checking an expression.
An ExpType can hold a &quot;hole&quot; that can be filled in by the type-checker.
This allows us to have one tcExpr that works in both checking mode and
synthesis mode (that is, bidirectional type-checking). Previously, this
was achieved by using ordinary unification variables, but we don't need
or want that generality. (For example, #11397 was caused by doing the
wrong thing with unification variables.) Instead, we observe that these
holes should

1. never be nested
2. never appear as the type of a variable
3. be used linearly (never be duplicated)

By defining ExpType, separately from Type, we can achieve goals 1 and 2
statically.

See also [wiki:typechecking]

Note [TcLevel of ExpType]
~~~~~~~~~~~~~~~~~~~~~~~~~
Consider

  data G a where
    MkG :: G Bool

  foo MkG = True

This is a classic untouchable-variable / ambiguous GADT return type
scenario. But, with ExpTypes, we'll be inferring the type of the RHS.
We thus must track a TcLevel in an Inferring ExpType. If we try to
fill the ExpType and find that the TcLevels don't work out, we fill
the ExpType with a tau-tv at the low TcLevel, hopefully to be worked
out later by some means -- see fillInferResult, and Note [fillInferResult]

This behaviour triggered in test gadt/gadt-escape1.
-}</span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span class="hs-comment">-- actual data definition is in GHC.Tc.Utils.TcType</span><span>
</span><span id="line-433"></span><span>
</span><span id="line-434"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newInferExpType"><span class="hs-identifier hs-type">newInferExpType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span>
</span><span id="line-435"></span><span id="newInferExpType"><span class="annot"><span class="annottext">newInferExpType :: TcM ExpType
</span><a href="GHC.Tc.Utils.TcMType.html#newInferExpType"><span class="hs-identifier hs-var hs-var">newInferExpType</span></a></span></span><span>
</span><span id="line-436"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078115"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078115"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-437"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078113"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078113"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-438"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newInferExpType&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078115"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078113"><span class="hs-identifier hs-var">tclvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-439"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078111"><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078111"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) (IORef (Maybe Kind))
forall a env. a -&gt; IOEnv env (IORef a)
</span><a href="GHC.Data.IOEnv.html#newMutVar"><span class="hs-identifier hs-var">newMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Kind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-440"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; TcM ExpType
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InferResult -&gt; ExpType
</span><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-var">Infer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IR :: Unique -&gt; TcLevel -&gt; IORef (Maybe Kind) -&gt; InferResult
</span><a href="GHC.Tc.Utils.TcType.html#IR"><span class="hs-identifier hs-type">IR</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ir_uniq :: Unique
</span><a href="GHC.Tc.Utils.TcType.html#ir_uniq"><span class="hs-identifier hs-var">ir_uniq</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078115"><span class="hs-identifier hs-var">u</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ir_lvl :: TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#ir_lvl"><span class="hs-identifier hs-var">ir_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078113"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-441"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ir_ref :: IORef (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcType.html#ir_ref"><span class="hs-identifier hs-var">ir_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078111"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-442"></span><span>
</span><span id="line-443"></span><span class="hs-comment">-- | Extract a type out of an ExpType, if one exists. But one should always</span><span>
</span><span id="line-444"></span><span class="hs-comment">-- exist. Unless you're quite sure you know what you're doing.</span><span>
</span><span id="line-445"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readExpType_maybe"><span class="hs-identifier hs-type">readExpType_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-446"></span><span id="readExpType_maybe"><span class="annot"><span class="annottext">readExpType_maybe :: ExpType -&gt; TcM (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType_maybe"><span class="hs-identifier hs-var hs-var">readExpType_maybe</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681078104"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078104"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Kind -&gt; TcM (Maybe Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078104"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-447"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readExpType_maybe"><span class="hs-identifier hs-var">readExpType_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-type">Infer</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#IR"><span class="hs-identifier hs-type">IR</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ir_ref :: InferResult -&gt; IORef (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcType.html#ir_ref"><span class="hs-identifier hs-var">ir_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078103"><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078103"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind) -&gt; TcM (Maybe Kind)
forall a env. IORef a -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#readMutVar"><span class="hs-identifier hs-var">readMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078103"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span class="hs-comment">-- | Same as readExpType, but for Scaled ExpTypes</span><span>
</span><span id="line-450"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readScaledExpType"><span class="hs-identifier hs-type">readScaledExpType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-451"></span><span id="readScaledExpType"><span class="annot"><span class="annottext">readScaledExpType :: Scaled ExpType -&gt; TcM (Scaled Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#readScaledExpType"><span class="hs-identifier hs-var hs-var">readScaledExpType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681078100"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078100"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681078099"><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078099"><span class="hs-identifier hs-var">exp_ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-452"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078098"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078098"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var">readExpType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078099"><span class="hs-identifier hs-var">exp_ty</span></a></span><span>
</span><span id="line-453"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Scaled Kind -&gt; TcM (Scaled Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Kind -&gt; Scaled Kind
forall a. Kind -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078100"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078098"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-454"></span><span>
</span><span id="line-455"></span><span class="hs-comment">-- | Extract a type out of an ExpType. Otherwise, panics.</span><span>
</span><span id="line-456"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-type">readExpType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-457"></span><span id="readExpType"><span class="annot"><span class="annottext">readExpType :: ExpType -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var hs-var">readExpType</span></a></span></span><span> </span><span id="local-6989586621681078097"><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078097"><span class="hs-identifier hs-var">exp_ty</span></a></span></span><span>
</span><span id="line-458"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078096"><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681078096"><span class="hs-identifier hs-var">mb_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; TcM (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType_maybe"><span class="hs-identifier hs-var">readExpType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078097"><span class="hs-identifier hs-var">exp_ty</span></a></span><span>
</span><span id="line-459"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681078096"><span class="hs-identifier hs-var">mb_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-460"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681078095"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078095"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078095"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-461"></span><span>           </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM Kind
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unknown expected type&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ExpType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078097"><span class="hs-identifier hs-var">exp_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-462"></span><span>
</span><span id="line-463"></span><span class="hs-comment">-- | Returns the expected type when in checking mode.</span><span>
</span><span id="line-464"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkingExpType_maybe"><span class="hs-identifier hs-type">checkingExpType_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-465"></span><span id="checkingExpType_maybe"><span class="annot"><span class="annottext">checkingExpType_maybe :: ExpType -&gt; Maybe Kind
</span><a href="GHC.Tc.Utils.TcMType.html#checkingExpType_maybe"><span class="hs-identifier hs-var hs-var">checkingExpType_maybe</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681078094"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078094"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078094"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-466"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkingExpType_maybe"><span class="hs-identifier hs-var">checkingExpType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-467"></span><span>
</span><span id="line-468"></span><span class="hs-comment">-- | Returns the expected type when in checking mode. Panics if in inference</span><span>
</span><span id="line-469"></span><span class="hs-comment">-- mode.</span><span>
</span><span id="line-470"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkingExpType"><span class="hs-identifier hs-type">checkingExpType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-471"></span><span id="checkingExpType"><span class="annot"><span class="annottext">checkingExpType :: String -&gt; ExpType -&gt; Kind
</span><a href="GHC.Tc.Utils.TcMType.html#checkingExpType"><span class="hs-identifier hs-var hs-var">checkingExpType</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681078093"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078093"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078093"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-472"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkingExpType"><span class="hs-identifier hs-var">checkingExpType</span></a></span><span> </span><span id="local-6989586621681078092"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681078092"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span id="local-6989586621681078091"><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078091"><span class="hs-identifier hs-var">et</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Kind
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkingExpType&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681078092"><span class="hs-identifier hs-var">err</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078091"><span class="hs-identifier hs-var">et</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-473"></span><span>
</span><span id="line-474"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#scaledExpTypeToType"><span class="hs-identifier hs-type">scaledExpTypeToType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span id="scaledExpTypeToType"><span class="annot"><span class="annottext">scaledExpTypeToType :: Scaled ExpType -&gt; TcM (Scaled Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#scaledExpTypeToType"><span class="hs-identifier hs-var hs-var">scaledExpTypeToType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681078089"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078089"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621681078088"><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078088"><span class="hs-identifier hs-var">exp_ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-476"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078087"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078087"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#expTypeToType"><span class="hs-identifier hs-var">expTypeToType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078088"><span class="hs-identifier hs-var">exp_ty</span></a></span><span>
</span><span id="line-477"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Scaled Kind -&gt; TcM (Scaled Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Kind -&gt; Scaled Kind
forall a. Kind -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078089"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078087"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span class="hs-comment">-- | Extracts the expected type if there is one, or generates a new</span><span>
</span><span id="line-480"></span><span class="hs-comment">-- TauTv if there isn't.</span><span>
</span><span id="line-481"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#expTypeToType"><span class="hs-identifier hs-type">expTypeToType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpType"><span class="hs-identifier hs-type">ExpType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-482"></span><span id="expTypeToType"><span class="annot"><span class="annottext">expTypeToType :: ExpType -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#expTypeToType"><span class="hs-identifier hs-var hs-var">expTypeToType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Check"><span class="hs-identifier hs-type">Check</span></a></span><span> </span><span id="local-6989586621681078086"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078086"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078086"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-483"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#expTypeToType"><span class="hs-identifier hs-var">expTypeToType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Infer"><span class="hs-identifier hs-type">Infer</span></a></span><span> </span><span id="local-6989586621681078085"><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681078085"><span class="hs-identifier hs-var">inf_res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InferResult -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#inferResultToType"><span class="hs-identifier hs-var">inferResultToType</span></a></span><span> </span><span class="annot"><span class="annottext">InferResult
</span><a href="#local-6989586621681078085"><span class="hs-identifier hs-var">inf_res</span></a></span><span>
</span><span id="line-484"></span><span>
</span><span id="line-485"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#inferResultToType"><span class="hs-identifier hs-type">inferResultToType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#InferResult"><span class="hs-identifier hs-type">InferResult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-486"></span><span id="inferResultToType"><span class="annot"><span class="annottext">inferResultToType :: InferResult -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#inferResultToType"><span class="hs-identifier hs-var hs-var">inferResultToType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#IR"><span class="hs-identifier hs-type">IR</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ir_uniq :: InferResult -&gt; Unique
</span><a href="GHC.Tc.Utils.TcType.html#ir_uniq"><span class="hs-identifier hs-var">ir_uniq</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078084"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078084"><span class="hs-identifier hs-var">u</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ir_lvl :: InferResult -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#ir_lvl"><span class="hs-identifier hs-var">ir_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078083"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078083"><span class="hs-identifier hs-var">tc_lvl</span></a></span></span><span>
</span><span id="line-487"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ir_ref :: InferResult -&gt; IORef (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcType.html#ir_ref"><span class="hs-identifier hs-var">ir_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078082"><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078082"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078081"><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681078081"><span class="hs-identifier hs-var">mb_inferred_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind) -&gt; TcM (Maybe Kind)
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078082"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-489"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078080"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078080"><span class="hs-identifier hs-var">tau</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681078081"><span class="hs-identifier hs-var">mb_inferred_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-490"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681078079"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078079"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#ensureMonoType"><span class="hs-identifier hs-var">ensureMonoType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078079"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-491"></span><span>                            </span><span class="hs-comment">-- See Note [inferResultToType]</span><span>
</span><span id="line-492"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078079"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-493"></span><span>            </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078077"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078077"><span class="hs-identifier hs-var">rr</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier hs-var">newMetaTyVarTyAtLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078083"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#runtimeRepTy"><span class="hs-identifier hs-var">runtimeRepTy</span></a></span><span>
</span><span id="line-494"></span><span>                          </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078075"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078075"><span class="hs-identifier hs-var">tau</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier hs-var">newMetaTyVarTyAtLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078083"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Kind
</span><a href="GHC.Builtin.Types.Prim.html#tYPE"><span class="hs-identifier hs-var">tYPE</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078077"><span class="hs-identifier hs-var">rr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-495"></span><span>                            </span><span class="hs-comment">-- See Note [TcLevel of ExpType]</span><span>
</span><span id="line-496"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind) -&gt; Maybe Kind -&gt; TcRn ()
forall a env. IORef a -&gt; a -&gt; IOEnv env ()
</span><a href="GHC.Data.IOEnv.html#writeMutVar"><span class="hs-identifier hs-var">writeMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078082"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078075"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-497"></span><span>                          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078075"><span class="hs-identifier hs-var">tau</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-498"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Forcing ExpType to be monomorphic:&quot;</span></span><span>
</span><span id="line-499"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078084"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078080"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-500"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078080"><span class="hs-identifier hs-var">tau</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-501"></span><span>
</span><span id="line-502"></span><span class="hs-comment">{- Note [inferResultToType]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
expTypeToType and inferResultType convert an InferResult to a monotype.
It must be a monotype because if the InferResult isn't already filled in,
we fill it in with a unification variable (hence monotype).  So to preserve
order-independence we check for mono-type-ness even if it *is* filled in
already.

See also Note [TcLevel of ExpType] above, and
Note [fillInferResult].
-}</span><span>
</span><span id="line-513"></span><span>
</span><span id="line-514"></span><span class="hs-comment">-- | Infer a type using a fresh ExpType</span><span>
</span><span id="line-515"></span><span class="hs-comment">-- See also Note [ExpType] in &quot;GHC.Tc.Utils.TcMType&quot;</span><span>
</span><span id="line-516"></span><span id="local-6989586621681078984"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tcInfer"><span class="hs-identifier hs-type">tcInfer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpSigmaType"><span class="hs-identifier hs-type">ExpSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681078984"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681078984"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-517"></span><span id="tcInfer"><span class="annot"><span class="annottext">tcInfer :: forall a. (ExpType -&gt; TcM a) -&gt; TcM (a, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#tcInfer"><span class="hs-identifier hs-var hs-var">tcInfer</span></a></span></span><span> </span><span id="local-6989586621681078067"><span class="annot"><span class="annottext">ExpType -&gt; TcM a
</span><a href="#local-6989586621681078067"><span class="hs-identifier hs-var">tc_check</span></a></span></span><span>
</span><span id="line-518"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078066"><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078066"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM ExpType
</span><a href="GHC.Tc.Utils.TcMType.html#newInferExpType"><span class="hs-identifier hs-var">newInferExpType</span></a></span><span>
</span><span id="line-519"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078065"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681078065"><span class="hs-identifier hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; TcM a
</span><a href="#local-6989586621681078067"><span class="hs-identifier hs-var">tc_check</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078066"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-520"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078064"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078064"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpType -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var">readExpType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpType
</span><a href="#local-6989586621681078066"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-521"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, Kind) -&gt; TcM (a, Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681078065"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078064"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-522"></span><span>
</span><span id="line-523"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#fillInferResult"><span class="hs-identifier hs-type">fillInferResult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#InferResult"><span class="hs-identifier hs-type">InferResult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercionN"><span class="hs-identifier hs-type">TcCoercionN</span></a></span><span>
</span><span id="line-524"></span><span class="hs-comment">-- If co = fillInferResult t1 t2</span><span>
</span><span id="line-525"></span><span class="hs-comment">--    =&gt; co :: t1 ~ t2</span><span>
</span><span id="line-526"></span><span class="hs-comment">-- See Note [fillInferResult]</span><span>
</span><span id="line-527"></span><span id="fillInferResult"><span class="annot"><span class="annottext">fillInferResult :: Kind -&gt; InferResult -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#fillInferResult"><span class="hs-identifier hs-var hs-var">fillInferResult</span></a></span></span><span> </span><span id="local-6989586621681078062"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078062"><span class="hs-identifier hs-var">act_res_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#IR"><span class="hs-identifier hs-type">IR</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ir_uniq :: InferResult -&gt; Unique
</span><a href="GHC.Tc.Utils.TcType.html#ir_uniq"><span class="hs-identifier hs-var">ir_uniq</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078061"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078061"><span class="hs-identifier hs-var">u</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ir_lvl :: InferResult -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#ir_lvl"><span class="hs-identifier hs-var">ir_lvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078060"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078060"><span class="hs-identifier hs-var">res_lvl</span></a></span></span><span>
</span><span id="line-528"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ir_ref :: InferResult -&gt; IORef (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcType.html#ir_ref"><span class="hs-identifier hs-var">ir_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681078059"><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078059"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-529"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078058"><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681078058"><span class="hs-identifier hs-var">mb_exp_res_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind) -&gt; TcM (Maybe Kind)
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078059"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-530"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681078058"><span class="hs-identifier hs-var">mb_exp_res_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-531"></span><span>            </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681078057"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078057"><span class="hs-identifier hs-var">exp_res_ty</span></a></span></span><span>
</span><span id="line-532"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Joining inferred ExpType&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-533"></span><span>                       </span><span class="annot"><span class="annottext">Unique -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078061"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078062"><span class="hs-identifier hs-var">act_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#char"><span class="hs-identifier hs-var">char</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'~'</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078057"><span class="hs-identifier hs-var">exp_res_ty</span></a></span><span>
</span><span id="line-534"></span><span>                     </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078055"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078055"><span class="hs-identifier hs-var">cur_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-535"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRn () -&gt; TcRn ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078055"><span class="hs-identifier hs-var">cur_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#sameDepthAs"><span class="hs-operator hs-var">`sameDepthAs`</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078060"><span class="hs-identifier hs-var">res_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-536"></span><span>                       </span><span class="annot"><span class="annottext">Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#ensureMonoType"><span class="hs-identifier hs-var">ensureMonoType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078062"><span class="hs-identifier hs-var">act_res_ty</span></a></span><span>
</span><span id="line-537"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; Kind -&gt; Kind -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078062"><span class="hs-identifier hs-var">act_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078057"><span class="hs-identifier hs-var">exp_res_ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-538"></span><span>            </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-539"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Filling inferred ExpType&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-540"></span><span>                       </span><span class="annot"><span class="annottext">Unique -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078061"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078062"><span class="hs-identifier hs-var">act_res_ty</span></a></span><span>
</span><span id="line-541"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681078052"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078052"><span class="hs-identifier hs-var">prom_co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681078051"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078051"><span class="hs-identifier hs-var">act_res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Kind -&gt; TcM (Coercion, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTcType"><span class="hs-identifier hs-var">promoteTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078060"><span class="hs-identifier hs-var">res_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078062"><span class="hs-identifier hs-var">act_res_ty</span></a></span><span>
</span><span id="line-542"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind) -&gt; Maybe Kind -&gt; TcRn ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">writeTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Kind)
</span><a href="#local-6989586621681078059"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078051"><span class="hs-identifier hs-var">act_res_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-543"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078052"><span class="hs-identifier hs-var">prom_co</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-544"></span><span>     </span><span class="hs-special">}</span><span>
</span><span id="line-545"></span><span>
</span><span id="line-546"></span><span>
</span><span id="line-547"></span><span class="hs-comment">{- Note [fillInferResult]
~~~~~~~~~~~~~~~~~~~~~~~~~
When inferring, we use fillInferResult to &quot;fill in&quot; the hole in InferResult
   data InferResult = IR { ir_uniq :: Unique
                         , ir_lvl  :: TcLevel
                         , ir_ref  :: IORef (Maybe TcType) }

There are two things to worry about:

1. What if it is under a GADT or existential pattern match?
   - GADTs: a unification variable (and Infer's hole is similar) is untouchable
   - Existentials: be careful about skolem-escape

2. What if it is filled in more than once?  E.g. multiple branches of a case
     case e of
        T1 -&gt; e1
        T2 -&gt; e2

Our typing rules are:

* The RHS of a existential or GADT alternative must always be a
  monotype, regardless of the number of alternatives.

* Multiple non-existential/GADT branches can have (the same)
  higher rank type (#18412).  E.g. this is OK:
      case e of
        True  -&gt; hr
        False -&gt; hr
  where hr:: (forall a. a-&gt;a) -&gt; Int
  c.f. Section 7.1 of &quot;Practical type inference for arbitrary-rank types&quot;
       We use choice (2) in that Section.
       (GHC 8.10 and earlier used choice (1).)

  But note that
      case e of
        True  -&gt; hr
        False -&gt; \x -&gt; hr x
  will fail, because we still /infer/ both branches, so the \x will get
  a (monotype) unification variable, which will fail to unify with
  (forall a. a-&gt;a)

For (1) we can detect the GADT/existential situation by seeing that
the current TcLevel is greater than that stored in ir_lvl of the Infer
ExpType.  We bump the level whenever we go past a GADT/existential match.

Then, before filling the hole use promoteTcType to promote the type
to the outer ir_lvl.  promoteTcType does this
  - create a fresh unification variable alpha at level ir_lvl
  - emits an equality alpha[ir_lvl] ~ ty
  - fills the hole with alpha
That forces the type to be a monotype (since unification variables can
only unify with monotypes); and catches skolem-escapes because the
alpha is untouchable until the equality floats out.

For (2), we simply look to see if the hole is filled already.
  - if not, we promote (as above) and fill the hole
  - if it is filled, we simply unify with the type that is
    already there

There is one wrinkle.  Suppose we have
   case e of
      T1 -&gt; e1 :: (forall a. a-&gt;a) -&gt; Int
      G2 -&gt; e2
where T1 is not GADT or existential, but G2 is a GADT.  Then supppose the
T1 alternative fills the hole with (forall a. a-&gt;a) -&gt; Int, which is fine.
But now the G2 alternative must not *just* unify with that else we'd risk
allowing through (e2 :: (forall a. a-&gt;a) -&gt; Int).  If we'd checked G2 first
we'd have filled the hole with a unification variable, which enforces a
monotype.

So if we check G2 second, we still want to emit a constraint that restricts
the RHS to be a monotype. This is done by ensureMonoType, and it works
by simply generating a constraint (alpha ~ ty), where alpha is a fresh
unification variable.  We discard the evidence.

-}</span><span>
</span><span id="line-623"></span><span>
</span><span id="line-624"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
              Promoting types
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#ensureMonoType"><span class="hs-identifier hs-type">ensureMonoType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-631"></span><span class="hs-comment">-- Assuming that the argument type is of kind (TYPE r),</span><span>
</span><span id="line-632"></span><span class="hs-comment">-- ensure that it is a /monotype/</span><span>
</span><span id="line-633"></span><span class="hs-comment">-- If it is not a monotype we can see right away (since unification</span><span>
</span><span id="line-634"></span><span class="hs-comment">-- varibles and type-function applications stand for monotypes), but</span><span>
</span><span id="line-635"></span><span class="hs-comment">-- we emit a Wanted equality just to delay the error message until later</span><span>
</span><span id="line-636"></span><span id="ensureMonoType"><span class="annot"><span class="annottext">ensureMonoType :: Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#ensureMonoType"><span class="hs-identifier hs-var hs-var">ensureMonoType</span></a></span></span><span> </span><span id="local-6989586621681078050"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078050"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-637"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Bool
</span><a href="GHC.Core.Type.html#isTauTy"><span class="hs-identifier hs-var">isTauTy</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078050"><span class="hs-identifier hs-var">res_ty</span></a></span><span>   </span><span class="hs-comment">-- isTauTy doesn't need zonking or anything</span><span>
</span><span id="line-638"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-639"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-640"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078048"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078048"><span class="hs-identifier hs-var">mono_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenFlexiTyVarTy"><span class="hs-identifier hs-var">newOpenFlexiTyVarTy</span></a></span><span>
</span><span id="line-641"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078047"><span class="annot"><span class="annottext">eq_orig :: CtOrigin
</span><a href="#local-6989586621681078047"><span class="hs-identifier hs-var hs-var">eq_orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: Kind -&gt; Kind -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078050"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-642"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078048"><span class="hs-identifier hs-var">mono_ty</span></a></span><span>
</span><span id="line-643"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SDoc
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-644"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-645"></span><span>
</span><span id="line-646"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078041"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078041"><span class="hs-identifier hs-var">_co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TypeOrKind -&gt; Role -&gt; Kind -&gt; Kind -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier hs-var">emitWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078047"><span class="hs-identifier hs-var">eq_orig</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078050"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078048"><span class="hs-identifier hs-var">mono_ty</span></a></span><span>
</span><span id="line-647"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-648"></span><span>
</span><span id="line-649"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTcType"><span class="hs-identifier hs-type">promoteTcType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercionN"><span class="hs-identifier hs-type">TcCoercionN</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-650"></span><span class="hs-comment">-- See Note [Promoting a type]</span><span>
</span><span id="line-651"></span><span class="hs-comment">-- See also Note [fillInferResult]</span><span>
</span><span id="line-652"></span><span class="hs-comment">-- promoteTcType level ty = (co, ty')</span><span>
</span><span id="line-653"></span><span class="hs-comment">--   * Returns ty'  whose max level is just 'level'</span><span>
</span><span id="line-654"></span><span class="hs-comment">--             and  whose kind is ~# to the kind of 'ty'</span><span>
</span><span id="line-655"></span><span class="hs-comment">--             and  whose kind has form TYPE rr</span><span>
</span><span id="line-656"></span><span class="hs-comment">--   * and co :: ty ~ ty'</span><span>
</span><span id="line-657"></span><span class="hs-comment">--   * and emits constraints to justify the coercion</span><span>
</span><span id="line-658"></span><span class="hs-comment">--</span><span>
</span><span id="line-659"></span><span class="hs-comment">-- NB: we expect that 'ty' has already kind (TYPE rr) for</span><span>
</span><span id="line-660"></span><span class="hs-comment">--     some rr::RuntimeRep.  It is, after all, the type of a term.</span><span>
</span><span id="line-661"></span><span id="promoteTcType"><span class="annot"><span class="annottext">promoteTcType :: TcLevel -&gt; Kind -&gt; TcM (Coercion, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTcType"><span class="hs-identifier hs-var hs-var">promoteTcType</span></a></span></span><span> </span><span id="local-6989586621681078039"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078039"><span class="hs-identifier hs-var">dest_lvl</span></a></span></span><span> </span><span id="local-6989586621681078038"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078038"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-662"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078037"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078037"><span class="hs-identifier hs-var">cur_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-663"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078037"><span class="hs-identifier hs-var">cur_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#sameDepthAs"><span class="hs-operator hs-var">`sameDepthAs`</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078039"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-664"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(Coercion, Kind) -&gt; TcM (Coercion, Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Coercion
</span><a href="GHC.Tc.Types.Evidence.html#mkTcNomReflCo"><span class="hs-identifier hs-var">mkTcNomReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078038"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078038"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-665"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, Kind)
</span><a href="#local-6989586621681078035"><span class="hs-identifier hs-var">promote_it</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-666"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-667"></span><span>    </span><span class="annot"><a href="#local-6989586621681078035"><span class="hs-identifier hs-type">promote_it</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-668"></span><span>    </span><span id="local-6989586621681078035"><span class="annot"><span class="annottext">promote_it :: TcM (Coercion, Kind)
</span><a href="#local-6989586621681078035"><span class="hs-identifier hs-var hs-var">promote_it</span></a></span></span><span>  </span><span class="hs-comment">-- Emit a constraint  (alpha :: TYPE rr) ~ ty</span><span>
</span><span id="line-669"></span><span>                </span><span class="hs-comment">-- where alpha and rr are fresh and from level dest_lvl</span><span>
</span><span id="line-670"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078033"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078033"><span class="hs-identifier hs-var">rr</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier hs-var">newMetaTyVarTyAtLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078039"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#runtimeRepTy"><span class="hs-identifier hs-var">runtimeRepTy</span></a></span><span>
</span><span id="line-671"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078032"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078032"><span class="hs-identifier hs-var">prom_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier hs-var">newMetaTyVarTyAtLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078039"><span class="hs-identifier hs-var">dest_lvl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Kind
</span><a href="GHC.Builtin.Types.Prim.html#tYPE"><span class="hs-identifier hs-var">tYPE</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078033"><span class="hs-identifier hs-var">rr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-672"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078031"><span class="annot"><span class="annottext">eq_orig :: CtOrigin
</span><a href="#local-6989586621681078031"><span class="hs-identifier hs-var hs-var">eq_orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEqOrigin :: Kind -&gt; Kind -&gt; Maybe SDoc -&gt; Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078038"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-673"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078032"><span class="hs-identifier hs-var">prom_ty</span></a></span><span>
</span><span id="line-674"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_thing :: Maybe SDoc
</span><a href="GHC.Tc.Types.Origin.html#uo_thing"><span class="hs-identifier hs-var">uo_thing</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SDoc
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-675"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_visible :: Bool
</span><a href="GHC.Tc.Types.Origin.html#uo_visible"><span class="hs-identifier hs-var">uo_visible</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-676"></span><span>
</span><span id="line-677"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078030"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078030"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TypeOrKind -&gt; Role -&gt; Kind -&gt; Kind -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier hs-var">emitWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681078031"><span class="hs-identifier hs-var">eq_orig</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078038"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078032"><span class="hs-identifier hs-var">prom_ty</span></a></span><span>
</span><span id="line-678"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Coercion, Kind) -&gt; TcM (Coercion, Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681078030"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078032"><span class="hs-identifier hs-var">prom_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-679"></span><span>
</span><span id="line-680"></span><span class="hs-comment">{- Note [Promoting a type]
~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (#12427)

  data T where
    MkT :: (Int -&gt; Int) -&gt; a -&gt; T

  h y = case y of MkT v w -&gt; v

We'll infer the RHS type with an expected type ExpType of
  (IR { ir_lvl = l, ir_ref = ref, ... )
where 'l' is the TcLevel of the RHS of 'h'.  Then the MkT pattern
match will increase the level, so we'll end up in tcSubType, trying to
unify the type of v,
  v :: Int -&gt; Int
with the expected type.  But this attempt takes place at level (l+1),
rightly so, since v's type could have mentioned existential variables,
(like w's does) and we want to catch that.

So we
  - create a new meta-var alpha[l+1]
  - fill in the InferRes ref cell 'ref' with alpha
  - emit an equality constraint, thus
        [W] alpha[l+1] ~ (Int -&gt; Int)

That constraint will float outwards, as it should, unless v's
type mentions a skolem-captured variable.

This approach fails if v has a higher rank type; see
Note [Promotion and higher rank types]


Note [Promotion and higher rank types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If v had a higher-rank type, say v :: (forall a. a-&gt;a) -&gt; Int,
then we'd emit an equality
        [W] alpha[l+1] ~ ((forall a. a-&gt;a) -&gt; Int)
which will sadly fail because we can't unify a unification variable
with a polytype.  But there is nothing really wrong with the program
here.

We could just about solve this by &quot;promote the type&quot; of v, to expose
its polymorphic &quot;shape&quot; while still leaving constraints that will
prevent existential escape.  But we must be careful!  Exposing
the &quot;shape&quot; of the type is precisely what we must NOT do under
a GADT pattern match!  So in this case we might promote the type
to
        (forall a. a-&gt;a) -&gt; alpha[l+1]
and emit the constraint
        [W] alpha[l+1] ~ Int
Now the promoted type can fill the ref cell, while the emitted
equality can float or not, according to the usual rules.

But that's not quite right!  We are exposing the arrow! We could
deal with that too:
        (forall a. mu[l+1] a a) -&gt; alpha[l+1]
with constraints
        [W] alpha[l+1] ~ Int
        [W] mu[l+1] ~ (-&gt;)
Here we abstract over the '-&gt;' inside the forall, in case that
is subject to an equality constraint from a GADT match.

Note that we kept the outer (-&gt;) because that's part of
the polymorphic &quot;shape&quot;.  And because of impredicativity,
GADT matches can't give equalities that affect polymorphic
shape.

This reasoning just seems too complicated, so I decided not
to do it.  These higher-rank notes are just here to record
the thinking.
-}</span><span>
</span><span id="line-751"></span><span>
</span><span id="line-752"></span><span>
</span><span id="line-753"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
        MetaTvs (meta type variables; mutable)
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-758"></span><span>
</span><span id="line-759"></span><span class="hs-comment">{- Note [TyVarTv]
~~~~~~~~~~~~~~~~~

A TyVarTv can unify with type *variables* only, including other TyVarTvs and
skolems. Sometimes, they can unify with type variables that the user would
rather keep distinct; see #11203 for an example.  So, any client of this
function needs to either allow the TyVarTvs to unify with each other or check
that they don't (say, with a call to findDubTyVarTvs).

Before #15050 this (under the name SigTv) was used for ScopedTypeVariables in
patterns, to make sure these type variables only refer to other type variables,
but this restriction was dropped, and ScopedTypeVariables can now refer to full
types (GHC Proposal 29).

The remaining uses of newTyVarTyVars are
* In kind signatures, see
  GHC.Tc.TyCl Note [Inferring kinds for type declarations]
           and Note [Kind checking for GADTs]
* In partial type signatures, see Note [Quantified variables in partial type signatures]
-}</span><span>
</span><span id="line-779"></span><span>
</span><span id="line-780"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-type">newMetaTyVarName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-781"></span><span class="hs-comment">-- Makes a /System/ Name, which is eagerly eliminated by</span><span>
</span><span id="line-782"></span><span class="hs-comment">-- the unifier; see GHC.Tc.Utils.Unify.nicer_to_update_tv1, and</span><span>
</span><span id="line-783"></span><span class="hs-comment">-- GHC.Tc.Solver.Canonical.canEqTyVarTyVar (nicer_to_update_tv2)</span><span>
</span><span id="line-784"></span><span id="newMetaTyVarName"><span class="annot"><span class="annottext">newMetaTyVarName :: FastString -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-var hs-var">newMetaTyVarName</span></a></span></span><span> </span><span id="local-6989586621681078029"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681078029"><span class="hs-identifier hs-var">str</span></a></span></span><span>
</span><span id="line-785"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078028"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078028"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-786"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; Name
</span><a href="GHC.Types.Name.html#mkSystemName"><span class="hs-identifier hs-var">mkSystemName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078028"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FastString -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkTyVarOccFS"><span class="hs-identifier hs-var">mkTyVarOccFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681078029"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-787"></span><span>
</span><span id="line-788"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVarName"><span class="hs-identifier hs-type">cloneMetaTyVarName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-789"></span><span id="cloneMetaTyVarName"><span class="annot"><span class="annottext">cloneMetaTyVarName :: Name -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVarName"><span class="hs-identifier hs-var hs-var">cloneMetaTyVarName</span></a></span></span><span> </span><span id="local-6989586621681078024"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078024"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-790"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078023"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078023"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-791"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Name
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; Name
</span><a href="GHC.Types.Name.html#mkSystemName"><span class="hs-identifier hs-var">mkSystemName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681078023"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078024"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-792"></span><span>         </span><span class="hs-comment">-- See Note [Name of an instantiated type variable]</span><span>
</span><span id="line-793"></span><span>
</span><span id="line-794"></span><span class="hs-comment">{- Note [Name of an instantiated type variable]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At the moment we give a unification variable a System Name, which
influences the way it is tidied; see TypeRep.tidyTyVarBndr.
-}</span><span>
</span><span id="line-799"></span><span>
</span><span id="line-800"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#metaInfoToTyVarName"><span class="hs-identifier hs-type">metaInfoToTyVarName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaInfo"><span class="hs-identifier hs-type">MetaInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span>
</span><span id="line-801"></span><span id="metaInfoToTyVarName"><span class="annot"><span class="annottext">metaInfoToTyVarName :: MetaInfo -&gt; FastString
</span><a href="GHC.Tc.Utils.TcMType.html#metaInfoToTyVarName"><span class="hs-identifier hs-var hs-var">metaInfoToTyVarName</span></a></span></span><span>  </span><span id="local-6989586621681078020"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078020"><span class="hs-identifier hs-var">meta_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-802"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078020"><span class="hs-identifier hs-var">meta_info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-803"></span><span>       </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;t&quot;</span></span><span>
</span><span id="line-804"></span><span>       </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#FlatMetaTv"><span class="hs-identifier hs-var">FlatMetaTv</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fmv&quot;</span></span><span>
</span><span id="line-805"></span><span>       </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#FlatSkolTv"><span class="hs-identifier hs-var">FlatSkolTv</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fsk&quot;</span></span><span>
</span><span id="line-806"></span><span>       </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;a&quot;</span></span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newAnonMetaTyVar"><span class="hs-identifier hs-type">newAnonMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaInfo"><span class="hs-identifier hs-type">MetaInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-809"></span><span id="newAnonMetaTyVar"><span class="annot"><span class="annottext">newAnonMetaTyVar :: MetaInfo -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newAnonMetaTyVar"><span class="hs-identifier hs-var hs-var">newAnonMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681078015"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078015"><span class="hs-identifier hs-var">mi</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString
-&gt; MetaInfo -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newNamedAnonMetaTyVar"><span class="hs-identifier hs-var">newNamedAnonMetaTyVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MetaInfo -&gt; FastString
</span><a href="GHC.Tc.Utils.TcMType.html#metaInfoToTyVarName"><span class="hs-identifier hs-var">metaInfoToTyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078015"><span class="hs-identifier hs-var">mi</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078015"><span class="hs-identifier hs-var">mi</span></a></span><span>
</span><span id="line-810"></span><span>
</span><span id="line-811"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newNamedAnonMetaTyVar"><span class="hs-identifier hs-type">newNamedAnonMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaInfo"><span class="hs-identifier hs-type">MetaInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-812"></span><span class="hs-comment">-- Make a new meta tyvar out of thin air</span><span>
</span><span id="line-813"></span><span id="newNamedAnonMetaTyVar"><span class="annot"><span class="annottext">newNamedAnonMetaTyVar :: FastString
-&gt; MetaInfo -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newNamedAnonMetaTyVar"><span class="hs-identifier hs-var hs-var">newNamedAnonMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681078013"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681078013"><span class="hs-identifier hs-var">tyvar_name</span></a></span></span><span> </span><span id="local-6989586621681078012"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078012"><span class="hs-identifier hs-var">meta_info</span></a></span></span><span> </span><span id="local-6989586621681078011"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078011"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-814"></span><span>
</span><span id="line-815"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078010"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078010"><span class="hs-identifier hs-var">name</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-var">newMetaTyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681078013"><span class="hs-identifier hs-var">tyvar_name</span></a></span><span>
</span><span id="line-816"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681078009"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681078009"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681078012"><span class="hs-identifier hs-var">meta_info</span></a></span><span>
</span><span id="line-817"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078008"><span class="annot"><span class="annottext">tyvar :: TyVar
</span><a href="#local-6989586621681078008"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078010"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078011"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681078009"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-818"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newAnonMetaTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078008"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-819"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078008"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-820"></span><span>
</span><span id="line-821"></span><span class="hs-comment">-- makes a new skolem tv</span><span>
</span><span id="line-822"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newSkolemTyVar"><span class="hs-identifier hs-type">newSkolemTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-823"></span><span id="newSkolemTyVar"><span class="annot"><span class="annottext">newSkolemTyVar :: Name -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newSkolemTyVar"><span class="hs-identifier hs-var hs-var">newSkolemTyVar</span></a></span></span><span> </span><span id="local-6989586621681078007"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078007"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681078006"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078006"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-824"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078005"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078005"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-825"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078007"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078006"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; Bool -&gt; TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-var">SkolemTv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681078005"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-826"></span><span>
</span><span id="line-827"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newTyVarTyVar"><span class="hs-identifier hs-type">newTyVarTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-828"></span><span class="hs-comment">-- See Note [TyVarTv]</span><span>
</span><span id="line-829"></span><span class="hs-comment">-- Does not clone a fresh unique</span><span>
</span><span id="line-830"></span><span id="newTyVarTyVar"><span class="annot"><span class="annottext">newTyVarTyVar :: Name -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newTyVarTyVar"><span class="hs-identifier hs-var hs-var">newTyVarTyVar</span></a></span></span><span> </span><span id="local-6989586621681078003"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078003"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681078002"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078002"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-831"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681078001"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681078001"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span>
</span><span id="line-832"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681078000"><span class="annot"><span class="annottext">tyvar :: TyVar
</span><a href="#local-6989586621681078000"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681078003"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681078002"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681078001"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-833"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newTyVarTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078000"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-834"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681078000"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-835"></span><span>
</span><span id="line-836"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneTyVarTyVar"><span class="hs-identifier hs-type">cloneTyVarTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-837"></span><span class="hs-comment">-- See Note [TyVarTv]</span><span>
</span><span id="line-838"></span><span class="hs-comment">-- Clones a fresh unique</span><span>
</span><span id="line-839"></span><span id="cloneTyVarTyVar"><span class="annot"><span class="annottext">cloneTyVarTyVar :: Name -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#cloneTyVarTyVar"><span class="hs-identifier hs-var hs-var">cloneTyVarTyVar</span></a></span></span><span> </span><span id="local-6989586621681077999"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077999"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681077998"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077998"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-840"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077997"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077997"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span>
</span><span id="line-841"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077996"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681077996"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-842"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077995"><span class="annot"><span class="annottext">name' :: Name
</span><a href="#local-6989586621681077995"><span class="hs-identifier hs-var hs-var">name'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077999"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Unique -&gt; Name
</span><a href="GHC.Types.Name.html#setNameUnique"><span class="hs-operator hs-var">`setNameUnique`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681077996"><span class="hs-identifier hs-var">uniq</span></a></span><span>
</span><span id="line-843"></span><span>             </span><span id="local-6989586621681077993"><span class="annot"><span class="annottext">tyvar :: TyVar
</span><a href="#local-6989586621681077993"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077995"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077998"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077997"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-844"></span><span>         </span><span class="hs-comment">-- Don't use cloneMetaTyVar, which makes a SystemName</span><span>
</span><span id="line-845"></span><span>         </span><span class="hs-comment">-- We want to keep the original more user-friendly Name</span><span>
</span><span id="line-846"></span><span>         </span><span class="hs-comment">-- In practical terms that means that in error messages,</span><span>
</span><span id="line-847"></span><span>         </span><span class="hs-comment">-- when the Name is tidied we get 'a' rather than 'a0'</span><span>
</span><span id="line-848"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cloneTyVarTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077993"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-849"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077993"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-850"></span><span>
</span><span id="line-851"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newPatSigTyVar"><span class="hs-identifier hs-type">newPatSigTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-852"></span><span id="newPatSigTyVar"><span class="annot"><span class="annottext">newPatSigTyVar :: Name -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newPatSigTyVar"><span class="hs-identifier hs-var hs-var">newPatSigTyVar</span></a></span></span><span> </span><span id="local-6989586621681077992"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077992"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681077991"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077991"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-853"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077990"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077990"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span>
</span><span id="line-854"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077989"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681077989"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-855"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077988"><span class="annot"><span class="annottext">name' :: Name
</span><a href="#local-6989586621681077988"><span class="hs-identifier hs-var hs-var">name'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077992"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Unique -&gt; Name
</span><a href="GHC.Types.Name.html#setNameUnique"><span class="hs-operator hs-var">`setNameUnique`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681077989"><span class="hs-identifier hs-var">uniq</span></a></span><span>
</span><span id="line-856"></span><span>             </span><span id="local-6989586621681077987"><span class="annot"><span class="annottext">tyvar :: TyVar
</span><a href="#local-6989586621681077987"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077988"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077991"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077990"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-857"></span><span>         </span><span class="hs-comment">-- Don't use cloneMetaTyVar;</span><span>
</span><span id="line-858"></span><span>         </span><span class="hs-comment">-- same reasoning as in newTyVarTyVar</span><span>
</span><span id="line-859"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newPatSigTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077987"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-860"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077987"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-861"></span><span>
</span><span id="line-862"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneAnonMetaTyVar"><span class="hs-identifier hs-type">cloneAnonMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaInfo"><span class="hs-identifier hs-type">MetaInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-863"></span><span class="hs-comment">-- Make a fresh MetaTyVar, basing the name</span><span>
</span><span id="line-864"></span><span class="hs-comment">-- on that of the supplied TyVar</span><span>
</span><span id="line-865"></span><span id="cloneAnonMetaTyVar"><span class="annot"><span class="annottext">cloneAnonMetaTyVar :: MetaInfo -&gt; TyVar -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#cloneAnonMetaTyVar"><span class="hs-identifier hs-var hs-var">cloneAnonMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077985"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681077985"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681077984"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077984"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681077983"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077983"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-866"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077982"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077982"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681077985"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-867"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077981"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077981"><span class="hs-identifier hs-var">name</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVarName"><span class="hs-identifier hs-var">cloneMetaTyVarName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077984"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-868"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077979"><span class="annot"><span class="annottext">tyvar :: TyVar
</span><a href="#local-6989586621681077979"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077981"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077983"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077982"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-869"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cloneAnonMetaTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077979"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077979"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-870"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077979"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-871"></span><span>
</span><span id="line-872"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFskTyVar"><span class="hs-identifier hs-type">newFskTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-873"></span><span id="newFskTyVar"><span class="annot"><span class="annottext">newFskTyVar :: Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newFskTyVar"><span class="hs-identifier hs-var hs-var">newFskTyVar</span></a></span></span><span> </span><span id="local-6989586621681077976"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077976"><span class="hs-identifier hs-var">fam_ty</span></a></span></span><span>
</span><span id="line-874"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077975"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077975"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#FlatSkolTv"><span class="hs-identifier hs-var">FlatSkolTv</span></a></span><span>
</span><span id="line-875"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077974"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077974"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-var">newMetaTyVarName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fsk&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-876"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077974"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Kind -&gt; Kind
Kind -&gt; Kind
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077976"><span class="hs-identifier hs-var">fam_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077975"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-877"></span><span>
</span><span id="line-878"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFmvTyVar"><span class="hs-identifier hs-type">newFmvTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-879"></span><span class="hs-comment">-- Very like newMetaTyVar, except sets mtv_tclvl to one less</span><span>
</span><span id="line-880"></span><span class="hs-comment">-- so that the fmv is untouchable.</span><span>
</span><span id="line-881"></span><span id="newFmvTyVar"><span class="annot"><span class="annottext">newFmvTyVar :: Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newFmvTyVar"><span class="hs-identifier hs-var hs-var">newFmvTyVar</span></a></span></span><span> </span><span id="local-6989586621681077972"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077972"><span class="hs-identifier hs-var">fam_ty</span></a></span></span><span>
</span><span id="line-882"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077971"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077971"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var">newMetaDetails</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#FlatMetaTv"><span class="hs-identifier hs-var">FlatMetaTv</span></a></span><span>
</span><span id="line-883"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077970"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077970"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-var">newMetaTyVarName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;s&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-884"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077970"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Kind -&gt; Kind
Kind -&gt; Kind
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077972"><span class="hs-identifier hs-var">fam_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077971"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-885"></span><span>
</span><span id="line-886"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-type">newMetaDetails</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaInfo"><span class="hs-identifier hs-type">MetaInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyVarDetails"><span class="hs-identifier hs-type">TcTyVarDetails</span></a></span><span>
</span><span id="line-887"></span><span id="newMetaDetails"><span class="annot"><span class="annottext">newMetaDetails :: MetaInfo -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaDetails"><span class="hs-identifier hs-var hs-var">newMetaDetails</span></a></span></span><span> </span><span id="local-6989586621681077969"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681077969"><span class="hs-identifier hs-var">info</span></a></span></span><span>
</span><span id="line-888"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077968"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077968"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaDetails -&gt; IOEnv (Env TcGblEnv TcLclEnv) (IORef MetaDetails)
forall a env. a -&gt; IOEnv env (IORef a)
</span><a href="GHC.Data.IOEnv.html#newMutVar"><span class="hs-identifier hs-var">newMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>
</span><span id="line-889"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077966"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077966"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-890"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails -&gt; TcM TcTyVarDetails
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MetaTv :: MetaInfo -&gt; IORef MetaDetails -&gt; TcLevel -&gt; TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_info :: MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#mtv_info"><span class="hs-identifier hs-var">mtv_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681077969"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-891"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077968"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-892"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mtv_tclvl :: TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#mtv_tclvl"><span class="hs-identifier hs-var">mtv_tclvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077966"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-893"></span><span>
</span><span id="line-894"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newTauTvDetailsAtLevel"><span class="hs-identifier hs-type">newTauTvDetailsAtLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyVarDetails"><span class="hs-identifier hs-type">TcTyVarDetails</span></a></span><span>
</span><span id="line-895"></span><span id="newTauTvDetailsAtLevel"><span class="annot"><span class="annottext">newTauTvDetailsAtLevel :: TcLevel -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newTauTvDetailsAtLevel"><span class="hs-identifier hs-var hs-var">newTauTvDetailsAtLevel</span></a></span></span><span> </span><span id="local-6989586621681077961"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077961"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span>
</span><span id="line-896"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077960"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077960"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaDetails -&gt; IOEnv (Env TcGblEnv TcLclEnv) (IORef MetaDetails)
forall a env. a -&gt; IOEnv env (IORef a)
</span><a href="GHC.Data.IOEnv.html#newMutVar"><span class="hs-identifier hs-var">newMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>
</span><span id="line-897"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails -&gt; TcM TcTyVarDetails
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MetaTv :: MetaInfo -&gt; IORef MetaDetails -&gt; TcLevel -&gt; TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_info :: MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#mtv_info"><span class="hs-identifier hs-var">mtv_info</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span>
</span><span id="line-898"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077960"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-899"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mtv_tclvl :: TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#mtv_tclvl"><span class="hs-identifier hs-var">mtv_tclvl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077961"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-900"></span><span>
</span><span id="line-901"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVar"><span class="hs-identifier hs-type">cloneMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-902"></span><span id="cloneMetaTyVar"><span class="annot"><span class="annottext">cloneMetaTyVar :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVar"><span class="hs-identifier hs-var hs-var">cloneMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077959"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077959"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-903"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isTcTyVar</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-904"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077956"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077956"><span class="hs-identifier hs-var">ref</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaDetails -&gt; IOEnv (Env TcGblEnv TcLclEnv) (IORef MetaDetails)
forall a env. a -&gt; IOEnv env (IORef a)
</span><a href="GHC.Data.IOEnv.html#newMutVar"><span class="hs-identifier hs-var">newMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>
</span><span id="line-905"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077955"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077955"><span class="hs-identifier hs-var">name'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVarName"><span class="hs-identifier hs-var">cloneMetaTyVarName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077959"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-906"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077951"><span class="annot"><span class="annottext">details' :: TcTyVarDetails
</span><a href="#local-6989586621681077951"><span class="hs-identifier hs-var hs-var">details'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077959"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-907"></span><span>                           </span><span id="local-6989586621681077949"><span class="annot"><span class="annottext">details :: TcTyVarDetails
</span><a href="#local-6989586621681077949"><span class="hs-identifier hs-var">details</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077949"><span class="hs-identifier hs-var">details</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077956"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-908"></span><span>                           </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcTyVarDetails
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cloneMetaTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077959"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-909"></span><span>              </span><span id="local-6989586621681077948"><span class="annot"><span class="annottext">tyvar :: TyVar
</span><a href="#local-6989586621681077948"><span class="hs-identifier hs-var hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077955"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077959"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077951"><span class="hs-identifier hs-var">details'</span></a></span><span>
</span><span id="line-910"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;cloneMetaTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077948"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-911"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077948"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-912"></span><span>
</span><span id="line-913"></span><span class="hs-comment">-- Works for both type and kind variables</span><span>
</span><span id="line-914"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-type">readMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaDetails"><span class="hs-identifier hs-type">MetaDetails</span></a></span><span>
</span><span id="line-915"></span><span id="readMetaTyVar"><span class="annot"><span class="annottext">readMetaTyVar :: TyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var hs-var">readMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077947"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077947"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isMetaTyVar</span><span> </span><span class="hs-identifier">tyvar</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tyvar</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-916"></span><span>                      </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcM MetaDetails
forall a env. IORef a -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#readMutVar"><span class="hs-identifier hs-var">readMutVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#metaTyVarRef"><span class="hs-identifier hs-var">metaTyVarRef</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077947"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-917"></span><span>
</span><span id="line-918"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-type">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-919"></span><span id="isFilledMetaTyVar_maybe"><span class="annot"><span class="annottext">isFilledMetaTyVar_maybe :: TyVar -&gt; TcM (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var hs-var">isFilledMetaTyVar_maybe</span></a></span></span><span> </span><span id="local-6989586621681077944"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077944"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-920"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077943"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077943"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077944"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-921"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077942"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077942"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcM MetaDetails
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077943"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-922"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077942"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-923"></span><span>          </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681077940"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077940"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Kind -&gt; TcM (Maybe Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077940"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-924"></span><span>          </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe Kind -&gt; TcM (Maybe Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Kind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-925"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-926"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Kind -&gt; TcM (Maybe Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Kind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-927"></span><span>
</span><span id="line-928"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar"><span class="hs-identifier hs-type">isFilledMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-929"></span><span class="hs-comment">-- True of a filled-in (Indirect) meta type variable</span><span>
</span><span id="line-930"></span><span id="isFilledMetaTyVar"><span class="annot"><span class="annottext">isFilledMetaTyVar :: TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar"><span class="hs-identifier hs-var hs-var">isFilledMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077939"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077939"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Kind -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Kind -&gt; Bool)
-&gt; TcM (Maybe Kind) -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077939"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-931"></span><span>
</span><span id="line-932"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isUnfilledMetaTyVar"><span class="hs-identifier hs-type">isUnfilledMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-933"></span><span class="hs-comment">-- True of a un-filled-in (Flexi) meta type variable</span><span>
</span><span id="line-934"></span><span class="hs-comment">-- NB: Not the opposite of isFilledMetaTyVar</span><span>
</span><span id="line-935"></span><span id="isUnfilledMetaTyVar"><span class="annot"><span class="annottext">isUnfilledMetaTyVar :: TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#isUnfilledMetaTyVar"><span class="hs-identifier hs-var hs-var">isUnfilledMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077938"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077938"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-936"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077937"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077937"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077938"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-937"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077936"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077936"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcM MetaDetails
forall a env. IORef a -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#readMutVar"><span class="hs-identifier hs-var">readMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077937"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-938"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MetaDetails -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isFlexi"><span class="hs-identifier hs-var">isFlexi</span></a></span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077936"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-939"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-940"></span><span>
</span><span id="line-941"></span><span class="hs-comment">--------------------</span><span>
</span><span id="line-942"></span><span class="hs-comment">-- Works with both type and kind variables</span><span>
</span><span id="line-943"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-type">writeMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-944"></span><span class="hs-comment">-- Write into a currently-empty MetaTyVar</span><span>
</span><span id="line-945"></span><span>
</span><span id="line-946"></span><span id="writeMetaTyVar"><span class="annot"><span class="annottext">writeMetaTyVar :: TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var hs-var">writeMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077934"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077934"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span> </span><span id="local-6989586621681077933"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077933"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-947"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span>
</span><span id="line-948"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IORef MetaDetails -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVarRef"><span class="hs-identifier hs-var">writeMetaTyVarRef</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077934"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#metaTyVarRef"><span class="hs-identifier hs-var">metaTyVarRef</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077934"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077933"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-949"></span><span>
</span><span id="line-950"></span><span class="hs-comment">-- Everything from here on only happens if DEBUG is on</span><span>
</span><span id="line-951"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTcTyVar"><span class="hs-identifier hs-var">isTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077934"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-952"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">False</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Writing to non-tc tyvar&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tyvar</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-953"></span><span>    </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-954"></span><span>
</span><span id="line-955"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077932"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077932"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077934"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-956"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IORef MetaDetails -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVarRef"><span class="hs-identifier hs-var">writeMetaTyVarRef</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077934"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077932"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077933"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-957"></span><span>
</span><span id="line-958"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-959"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">False</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Writing to non-meta tyvar&quot;</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tyvar</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-960"></span><span>    </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-961"></span><span>
</span><span id="line-962"></span><span class="hs-comment">--------------------</span><span>
</span><span id="line-963"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVarRef"><span class="hs-identifier hs-type">writeMetaTyVarRef</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRef"><span class="hs-identifier hs-type">TcRef</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaDetails"><span class="hs-identifier hs-type">MetaDetails</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-964"></span><span class="hs-comment">-- Here the tyvar is for error checking only;</span><span>
</span><span id="line-965"></span><span class="hs-comment">-- the ref cell must be for the same tyvar</span><span>
</span><span id="line-966"></span><span id="writeMetaTyVarRef"><span class="annot"><span class="annottext">writeMetaTyVarRef :: TyVar -&gt; IORef MetaDetails -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVarRef"><span class="hs-identifier hs-var hs-var">writeMetaTyVarRef</span></a></span></span><span> </span><span id="local-6989586621681077931"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span> </span><span id="local-6989586621681077930"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077930"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span id="local-6989586621681077929"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-967"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span>
</span><span id="line-968"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;writeMetaTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-969"></span><span>                                   </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-970"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; MetaDetails -&gt; TcRn ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">writeTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077930"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-var">Indirect</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-971"></span><span>
</span><span id="line-972"></span><span>  </span><span class="hs-comment">-- Everything from here on only happens if DEBUG is on</span><span>
</span><span id="line-973"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-974"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077928"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077928"><span class="hs-identifier hs-var">meta_details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcM MetaDetails
forall a env. IORef a -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#readMutVar"><span class="hs-identifier hs-var">readMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077930"><span class="hs-identifier hs-var">ref</span></a></span><span class="hs-special">;</span><span>
</span><span id="line-975"></span><span>       </span><span class="hs-comment">-- Zonk kinds to allow the error check to work</span><span>
</span><span id="line-976"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077927"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077927"><span class="hs-identifier hs-var">zonked_tv_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077926"><span class="hs-identifier hs-var">tv_kind</span></a></span><span>
</span><span id="line-977"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077925"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077925"><span class="hs-identifier hs-var">zonked_ty_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077924"><span class="hs-identifier hs-var">ty_kind</span></a></span><span>
</span><span id="line-978"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077922"><span class="annot"><span class="annottext">kind_check_ok :: Bool
</span><a href="#local-6989586621681077922"><span class="hs-identifier hs-var hs-var">kind_check_ok</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Bool
</span><a href="GHC.Core.Type.html#tcIsConstraintKind"><span class="hs-identifier hs-var">tcIsConstraintKind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077927"><span class="hs-identifier hs-var">zonked_tv_kind</span></a></span><span>
</span><span id="line-979"></span><span>                          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Kind -&gt; Kind -&gt; Bool
Kind -&gt; Kind -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqKind"><span class="hs-identifier hs-var">tcEqKind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077925"><span class="hs-identifier hs-var">zonked_ty_kind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077927"><span class="hs-identifier hs-var">zonked_tv_kind</span></a></span><span>
</span><span id="line-980"></span><span>             </span><span class="hs-comment">-- Hack alert! tcIsConstraintKind: see GHC.Tc.Gen.HsType</span><span>
</span><span id="line-981"></span><span>             </span><span class="hs-comment">-- Note [Extra-constraint holes in partial type signatures]</span><span>
</span><span id="line-982"></span><span>
</span><span id="line-983"></span><span>             </span><span id="local-6989586621681077913"><span class="annot"><span class="annottext">kind_msg :: SDoc
</span><a href="#local-6989586621681077913"><span class="hs-identifier hs-var hs-var">kind_msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Ill-kinded update to meta tyvar&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-984"></span><span>                           </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span>    </span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;::&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077926"><span class="hs-identifier hs-var">tv_kind</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077927"><span class="hs-identifier hs-var">zonked_tv_kind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-985"></span><span>                              </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span>
</span><span id="line-986"></span><span>                              </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;::&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077925"><span class="hs-identifier hs-var">zonked_ty_kind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-987"></span><span>
</span><span id="line-988"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;writeMetaTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-989"></span><span>
</span><span id="line-990"></span><span>       </span><span class="hs-comment">-- Check for double updates</span><span>
</span><span id="line-991"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isFlexi</span><span> </span><span class="hs-identifier">meta_details</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">double_upd_msg</span><span> </span><span class="hs-identifier">meta_details</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-992"></span><span>
</span><span id="line-993"></span><span>       </span><span class="hs-comment">-- Check for level OK</span><span>
</span><span id="line-994"></span><span>       </span><span class="hs-comment">-- See Note [Level check when unifying]</span><span>
</span><span id="line-995"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">level_check_ok</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">level_check_msg</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-996"></span><span>       </span><span class="hs-comment">-- another level check problem, see #97</span><span>
</span><span id="line-997"></span><span>
</span><span id="line-998"></span><span>       </span><span class="hs-comment">-- Check Kinds ok</span><span>
</span><span id="line-999"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">kind_check_ok</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">kind_msg</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1000"></span><span>
</span><span id="line-1001"></span><span>       </span><span class="hs-comment">-- Do the write</span><span>
</span><span id="line-1002"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; MetaDetails -&gt; TcRn ()
forall a env. IORef a -&gt; a -&gt; IOEnv env ()
</span><a href="GHC.Data.IOEnv.html#writeMutVar"><span class="hs-identifier hs-var">writeMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077930"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-var">Indirect</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1003"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1004"></span><span>    </span><span id="local-6989586621681077926"><span class="annot"><span class="annottext">tv_kind :: Kind
</span><a href="#local-6989586621681077926"><span class="hs-identifier hs-var hs-var">tv_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1005"></span><span>    </span><span id="local-6989586621681077924"><span class="annot"><span class="annottext">ty_kind :: Kind
</span><a href="#local-6989586621681077924"><span class="hs-identifier hs-var hs-var">ty_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Kind -&gt; Kind
Kind -&gt; Kind
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1006"></span><span>
</span><span id="line-1007"></span><span>    </span><span id="local-6989586621681077907"><span class="annot"><span class="annottext">tv_lvl :: TcLevel
</span><a href="#local-6989586621681077907"><span class="hs-identifier hs-var hs-var">tv_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#tcTyVarLevel"><span class="hs-identifier hs-var">tcTyVarLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1008"></span><span>    </span><span id="local-6989586621681077905"><span class="annot"><span class="annottext">ty_lvl :: TcLevel
</span><a href="#local-6989586621681077905"><span class="hs-identifier hs-var hs-var">ty_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#tcTypeLevel"><span class="hs-identifier hs-var">tcTypeLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1009"></span><span>
</span><span id="line-1010"></span><span>    </span><span id="local-6989586621681077910"><span class="annot"><span class="annottext">level_check_ok :: Bool
</span><a href="#local-6989586621681077910"><span class="hs-identifier hs-var hs-var">level_check_ok</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077905"><span class="hs-identifier hs-var">ty_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#strictlyDeeperThan"><span class="hs-operator hs-var">`strictlyDeeperThan`</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077907"><span class="hs-identifier hs-var">tv_lvl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1011"></span><span>    </span><span id="local-6989586621681077909"><span class="annot"><span class="annottext">level_check_msg :: SDoc
</span><a href="#local-6989586621681077909"><span class="hs-identifier hs-var hs-var">level_check_msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077905"><span class="hs-identifier hs-var">ty_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077907"><span class="hs-identifier hs-var">tv_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077929"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1012"></span><span>
</span><span id="line-1013"></span><span>    </span><span id="local-6989586621681077911"><span class="annot"><span class="annottext">double_upd_msg :: a -&gt; SDoc
</span><a href="#local-6989586621681077911"><span class="hs-identifier hs-var hs-var">double_upd_msg</span></a></span></span><span> </span><span id="local-6989586621681077895"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681077895"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Double update of meta tyvar&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1014"></span><span>                                </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077931"><span class="hs-identifier hs-var">tyvar</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681077895"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1015"></span><span>
</span><span id="line-1016"></span><span class="hs-comment">{- Note [Level check when unifying]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When unifying
     alpha:lvl := ty
we expect that the TcLevel of 'ty' will be &lt;= lvl.
However, during unflatting we do
     fuv:l := ty:(l+1)
which is usually wrong; hence the check isFmmvTyVar in level_check_ok.
See Note [TcLevel assignment] in GHC.Tc.Utils.TcType.
-}</span><span>
</span><span id="line-1026"></span><span>
</span><span id="line-1027"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTyVar"><span class="hs-identifier hs-type">promoteTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1028"></span><span class="hs-comment">-- When we float a constraint out of an implication we must restore</span><span>
</span><span id="line-1029"></span><span class="hs-comment">-- invariant (WantedInv) in Note [TcLevel and untouchable type variables] in GHC.Tc.Utils.TcType</span><span>
</span><span id="line-1030"></span><span class="hs-comment">-- Return True &lt;=&gt; we did some promotion</span><span>
</span><span id="line-1031"></span><span class="hs-comment">-- Also returns either the original tyvar (no promotion) or the new one</span><span>
</span><span id="line-1032"></span><span class="hs-comment">-- See Note [Promoting unification variables]</span><span>
</span><span id="line-1033"></span><span id="promoteTyVar"><span class="annot"><span class="annottext">promoteTyVar :: TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVar"><span class="hs-identifier hs-var hs-var">promoteTyVar</span></a></span></span><span> </span><span id="local-6989586621681077894"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077894"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1034"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077893"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077893"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-1035"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcLevel -&gt; TyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isFloatedTouchableMetaTyVar"><span class="hs-identifier hs-var">isFloatedTouchableMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077893"><span class="hs-identifier hs-var">tclvl</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077894"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1036"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077891"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077891"><span class="hs-identifier hs-var">cloned_tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#cloneMetaTyVar"><span class="hs-identifier hs-var">cloneMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077894"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1037"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077890"><span class="annot"><span class="annottext">rhs_tv :: TyVar
</span><a href="#local-6989586621681077890"><span class="hs-identifier hs-var hs-var">rhs_tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcLevel -&gt; TyVar
</span><a href="GHC.Tc.Utils.TcType.html#setMetaTyVarTcLevel"><span class="hs-identifier hs-var">setMetaTyVarTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077891"><span class="hs-identifier hs-var">cloned_tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077893"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-1038"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var">writeMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077894"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077890"><span class="hs-identifier hs-var">rhs_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1039"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1040"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1041"></span><span>
</span><span id="line-1042"></span><span class="hs-comment">-- Returns whether or not *any* tyvar is defaulted</span><span>
</span><span id="line-1043"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier hs-type">promoteTyVarSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyVarSet"><span class="hs-identifier hs-type">TcTyVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1044"></span><span id="promoteTyVarSet"><span class="annot"><span class="annottext">promoteTyVarSet :: TcTyVarSet -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVarSet"><span class="hs-identifier hs-var hs-var">promoteTyVarSet</span></a></span></span><span> </span><span id="local-6989586621681077888"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077888"><span class="hs-identifier hs-var">tvs</span></a></span></span><span>
</span><span id="line-1045"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077887"><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681077887"><span class="hs-identifier hs-var">bools</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool)
-&gt; [TyVar] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [Bool]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#promoteTyVar"><span class="hs-identifier hs-var">promoteTyVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet -&gt; [TyVar]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077888"><span class="hs-identifier hs-var">tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1046"></span><span>         </span><span class="hs-comment">-- Non-determinism is OK because order of promotion doesn't matter</span><span>
</span><span id="line-1047"></span><span>
</span><span id="line-1048"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Bool] -&gt; Bool
forall (t :: * -&gt; *). Foldable t =&gt; t Bool -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#or"><span class="hs-identifier hs-var">or</span></a></span><span> </span><span class="annot"><span class="annottext">[Bool]
</span><a href="#local-6989586621681077887"><span class="hs-identifier hs-var">bools</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1049"></span><span>
</span><span id="line-1050"></span><span>
</span><span id="line-1051"></span><span class="hs-comment">{-
% Generating fresh variables for pattern match check
-}</span><span>
</span><span id="line-1054"></span><span>
</span><span id="line-1055"></span><span>
</span><span id="line-1056"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        MetaTvs: TauTvs
*                                                                      *
************************************************************************

Note [Never need to instantiate coercion variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With coercion variables sloshing around in types, it might seem that we
sometimes need to instantiate coercion variables. This would be problematic,
because coercion variables inhabit unboxed equality (~#), and the constraint
solver thinks in terms only of boxed equality (~). The solution is that
we never need to instantiate coercion variables in the first place.

The tyvars that we need to instantiate come from the types of functions,
data constructors, and patterns. These will never be quantified over
coercion variables, except for the special case of the promoted Eq#. But,
that can't ever appear in user code, so we're safe!
-}</span><span>
</span><span id="line-1076"></span><span>
</span><span id="line-1077"></span><span>
</span><span id="line-1078"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMultiplicityVar"><span class="hs-identifier hs-type">newMultiplicityVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-1079"></span><span id="newMultiplicityVar"><span class="annot"><span class="annottext">newMultiplicityVar :: TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMultiplicityVar"><span class="hs-identifier hs-var hs-var">newMultiplicityVar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#multiplicityTy"><span class="hs-identifier hs-var">multiplicityTy</span></a></span><span>
</span><span id="line-1080"></span><span>
</span><span id="line-1081"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVar"><span class="hs-identifier hs-type">newFlexiTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-1082"></span><span id="newFlexiTyVar"><span class="annot"><span class="annottext">newFlexiTyVar :: Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVar"><span class="hs-identifier hs-var hs-var">newFlexiTyVar</span></a></span></span><span> </span><span id="local-6989586621681077883"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077883"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newAnonMetaTyVar"><span class="hs-identifier hs-var">newAnonMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077883"><span class="hs-identifier hs-var">kind</span></a></span><span>
</span><span id="line-1083"></span><span>
</span><span id="line-1084"></span><span class="hs-comment">-- | Create a new flexi ty var with a specific name</span><span>
</span><span id="line-1085"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newNamedFlexiTyVar"><span class="hs-identifier hs-type">newNamedFlexiTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-1086"></span><span id="newNamedFlexiTyVar"><span class="annot"><span class="annottext">newNamedFlexiTyVar :: FastString -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newNamedFlexiTyVar"><span class="hs-identifier hs-var hs-var">newNamedFlexiTyVar</span></a></span></span><span> </span><span id="local-6989586621681077882"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681077882"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span id="local-6989586621681077881"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077881"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastString
-&gt; MetaInfo -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newNamedAnonMetaTyVar"><span class="hs-identifier hs-var">newNamedAnonMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681077882"><span class="hs-identifier hs-var">fs</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077881"><span class="hs-identifier hs-var">kind</span></a></span><span>
</span><span id="line-1087"></span><span>
</span><span id="line-1088"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-type">newFlexiTyVarTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-1089"></span><span id="newFlexiTyVarTy"><span class="annot"><span class="annottext">newFlexiTyVarTy :: Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var hs-var">newFlexiTyVarTy</span></a></span></span><span> </span><span id="local-6989586621681077880"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077880"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-1090"></span><span>    </span><span id="local-6989586621681077879"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077879"><span class="hs-identifier hs-var">tc_tyvar</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVar"><span class="hs-identifier hs-var">newFlexiTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077880"><span class="hs-identifier hs-var">kind</span></a></span><span>
</span><span id="line-1091"></span><span>    </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077879"><span class="hs-identifier hs-var">tc_tyvar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1092"></span><span>
</span><span id="line-1093"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTys"><span class="hs-identifier hs-type">newFlexiTyVarTys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1094"></span><span id="newFlexiTyVarTys"><span class="annot"><span class="annottext">newFlexiTyVarTys :: Int -&gt; Kind -&gt; TcM [Kind]
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTys"><span class="hs-identifier hs-var hs-var">newFlexiTyVarTys</span></a></span></span><span> </span><span id="local-6989586621681077878"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681077878"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681077877"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077877"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TcM Kind -&gt; TcM [Kind]
forall (m :: * -&gt; *) a. Applicative m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="../../base/src/Control.Monad.html#replicateM"><span class="hs-identifier hs-var">replicateM</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681077878"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077877"><span class="hs-identifier hs-var">kind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1095"></span><span>
</span><span id="line-1096"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newOpenTypeKind"><span class="hs-identifier hs-type">newOpenTypeKind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span>
</span><span id="line-1097"></span><span id="newOpenTypeKind"><span class="annot"><span class="annottext">newOpenTypeKind :: TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenTypeKind"><span class="hs-identifier hs-var hs-var">newOpenTypeKind</span></a></span></span><span>
</span><span id="line-1098"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077876"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077876"><span class="hs-identifier hs-var">rr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#runtimeRepTy"><span class="hs-identifier hs-var">runtimeRepTy</span></a></span><span>
</span><span id="line-1099"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; Kind
</span><a href="GHC.Builtin.Types.Prim.html#tYPE"><span class="hs-identifier hs-var">tYPE</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077876"><span class="hs-identifier hs-var">rr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1100"></span><span>
</span><span id="line-1101"></span><span class="hs-comment">-- | Create a tyvar that can be a lifted or unlifted type.</span><span>
</span><span id="line-1102"></span><span class="hs-comment">-- Returns alpha :: TYPE kappa, where both alpha and kappa are fresh</span><span>
</span><span id="line-1103"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newOpenFlexiTyVarTy"><span class="hs-identifier hs-type">newOpenFlexiTyVarTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-1104"></span><span id="newOpenFlexiTyVarTy"><span class="annot"><span class="annottext">newOpenFlexiTyVarTy :: TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenFlexiTyVarTy"><span class="hs-identifier hs-var hs-var">newOpenFlexiTyVarTy</span></a></span></span><span>
</span><span id="line-1105"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077875"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077875"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenTypeKind"><span class="hs-identifier hs-var">newOpenTypeKind</span></a></span><span>
</span><span id="line-1106"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newFlexiTyVarTy"><span class="hs-identifier hs-var">newFlexiTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077875"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1107"></span><span>
</span><span id="line-1108"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVars"><span class="hs-identifier hs-type">newMetaTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1109"></span><span class="hs-comment">-- Instantiate with META type variables</span><span>
</span><span id="line-1110"></span><span class="hs-comment">-- Note that this works for a sequence of kind, type, and coercion variables</span><span>
</span><span id="line-1111"></span><span class="hs-comment">-- variables.  Eg    [ (k:*), (a:k-&gt;k) ]</span><span>
</span><span id="line-1112"></span><span class="hs-comment">--             Gives [ (k7:*), (a8:k7-&gt;k7) ]</span><span>
</span><span id="line-1113"></span><span id="newMetaTyVars"><span class="annot"><span class="annottext">newMetaTyVars :: [TyVar] -&gt; TcM (TCvSubst, [TyVar])
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVars"><span class="hs-identifier hs-var hs-var">newMetaTyVars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [TyVar] -&gt; TcM (TCvSubst, [TyVar])
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarsX"><span class="hs-identifier hs-var">newMetaTyVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span>
</span><span id="line-1114"></span><span>    </span><span class="hs-comment">-- emptyTCvSubst has an empty in-scope set, but that's fine here</span><span>
</span><span id="line-1115"></span><span>    </span><span class="hs-comment">-- Since the tyvars are freshly made, they cannot possibly be</span><span>
</span><span id="line-1116"></span><span>    </span><span class="hs-comment">-- captured by any existing for-alls.</span><span>
</span><span id="line-1117"></span><span>
</span><span id="line-1118"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarsX"><span class="hs-identifier hs-type">newMetaTyVarsX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1119"></span><span class="hs-comment">-- Just like newMetaTyVars, but start with an existing substitution.</span><span>
</span><span id="line-1120"></span><span id="newMetaTyVarsX"><span class="annot"><span class="annottext">newMetaTyVarsX :: TCvSubst -&gt; [TyVar] -&gt; TcM (TCvSubst, [TyVar])
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarsX"><span class="hs-identifier hs-var hs-var">newMetaTyVarsX</span></a></span></span><span> </span><span id="local-6989586621681077873"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077873"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst
 -&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar))
-&gt; TCvSubst -&gt; [TyVar] -&gt; TcM (TCvSubst, [TyVar])
forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var">mapAccumLM</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier hs-var">newMetaTyVarX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077873"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-1121"></span><span>
</span><span id="line-1122"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier hs-type">newMetaTyVarX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1123"></span><span class="hs-comment">-- Make a new unification variable tyvar whose Name and Kind come from</span><span>
</span><span id="line-1124"></span><span class="hs-comment">-- an existing TyVar. We substitute kind variables in the kind.</span><span>
</span><span id="line-1125"></span><span id="newMetaTyVarX"><span class="annot"><span class="annottext">newMetaTyVarX :: TCvSubst
-&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier hs-var hs-var">newMetaTyVarX</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo
-&gt; TCvSubst
-&gt; TyVar
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#new_meta_tv_x"><span class="hs-identifier hs-var">new_meta_tv_x</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span>
</span><span id="line-1126"></span><span>
</span><span id="line-1127"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyVarX"><span class="hs-identifier hs-type">newMetaTyVarTyVarX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1128"></span><span class="hs-comment">-- Just like newMetaTyVarX, but make a TyVarTv</span><span>
</span><span id="line-1129"></span><span id="newMetaTyVarTyVarX"><span class="annot"><span class="annottext">newMetaTyVarTyVarX :: TCvSubst
-&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyVarX"><span class="hs-identifier hs-var hs-var">newMetaTyVarTyVarX</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MetaInfo
-&gt; TCvSubst
-&gt; TyVar
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#new_meta_tv_x"><span class="hs-identifier hs-var">new_meta_tv_x</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TyVarTv"><span class="hs-identifier hs-var">TyVarTv</span></a></span><span>
</span><span id="line-1130"></span><span>
</span><span id="line-1131"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWildCardX"><span class="hs-identifier hs-type">newWildCardX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1132"></span><span id="newWildCardX"><span class="annot"><span class="annottext">newWildCardX :: TCvSubst
-&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#newWildCardX"><span class="hs-identifier hs-var hs-var">newWildCardX</span></a></span></span><span> </span><span id="local-6989586621681077870"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077870"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681077869"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077869"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1133"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077868"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077868"><span class="hs-identifier hs-var">new_tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#newAnonMetaTyVar"><span class="hs-identifier hs-var">newAnonMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="GHC.Tc.Utils.TcType.html#TauTv"><span class="hs-identifier hs-var">TauTv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Kind -&gt; Kind
TCvSubst -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077870"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077869"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1134"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, TyVar)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; TyVar -&gt; TyVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier hs-var">extendTvSubstWithClone</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077870"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077869"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077868"><span class="hs-identifier hs-var">new_tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077868"><span class="hs-identifier hs-var">new_tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1135"></span><span>
</span><span id="line-1136"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#new_meta_tv_x"><span class="hs-identifier hs-type">new_meta_tv_x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaInfo"><span class="hs-identifier hs-type">MetaInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1137"></span><span id="new_meta_tv_x"><span class="annot"><span class="annottext">new_meta_tv_x :: MetaInfo
-&gt; TCvSubst
-&gt; TyVar
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
</span><a href="GHC.Tc.Utils.TcMType.html#new_meta_tv_x"><span class="hs-identifier hs-var hs-var">new_meta_tv_x</span></a></span></span><span> </span><span id="local-6989586621681077865"><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681077865"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681077864"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077864"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681077863"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077863"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1138"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077862"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077862"><span class="hs-identifier hs-var">new_tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MetaInfo -&gt; TyVar -&gt; Kind -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#cloneAnonMetaTyVar"><span class="hs-identifier hs-var">cloneAnonMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">MetaInfo
</span><a href="#local-6989586621681077865"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077863"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077861"><span class="hs-identifier hs-var">substd_kind</span></a></span><span>
</span><span id="line-1139"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077860"><span class="annot"><span class="annottext">subst1 :: TCvSubst
</span><a href="#local-6989586621681077860"><span class="hs-identifier hs-var hs-var">subst1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyVar -&gt; TyVar -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier hs-var">extendTvSubstWithClone</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077864"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077863"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077862"><span class="hs-identifier hs-var">new_tv</span></a></span><span>
</span><span id="line-1140"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, TyVar)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, TyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077860"><span class="hs-identifier hs-var">subst1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077862"><span class="hs-identifier hs-var">new_tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1141"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1142"></span><span>    </span><span id="local-6989586621681077861"><span class="annot"><span class="annottext">substd_kind :: Kind
</span><a href="#local-6989586621681077861"><span class="hs-identifier hs-var hs-var">substd_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681077864"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077863"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1143"></span><span>      </span><span class="hs-comment">-- NOTE: #12549 is fixed so we could use</span><span>
</span><span id="line-1144"></span><span>      </span><span class="hs-comment">-- substTy here, but the tc_infer_args problem</span><span>
</span><span id="line-1145"></span><span>      </span><span class="hs-comment">-- is not yet fixed so leaving as unchecked for now.</span><span>
</span><span id="line-1146"></span><span>      </span><span class="hs-comment">-- OLD NOTE:</span><span>
</span><span id="line-1147"></span><span>      </span><span class="hs-comment">-- Unchecked because we call newMetaTyVarX from</span><span>
</span><span id="line-1148"></span><span>      </span><span class="hs-comment">-- tcInstTyBinder, which is called from tcInferTyApps</span><span>
</span><span id="line-1149"></span><span>      </span><span class="hs-comment">-- which does not yet take enough trouble to ensure</span><span>
</span><span id="line-1150"></span><span>      </span><span class="hs-comment">-- the in-scope set is right; e.g. #12785 trips</span><span>
</span><span id="line-1151"></span><span>      </span><span class="hs-comment">-- if we use substTy here</span><span>
</span><span id="line-1152"></span><span>
</span><span id="line-1153"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier hs-type">newMetaTyVarTyAtLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-1154"></span><span id="newMetaTyVarTyAtLevel"><span class="annot"><span class="annottext">newMetaTyVarTyAtLevel :: TcLevel -&gt; Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyAtLevel"><span class="hs-identifier hs-var hs-var">newMetaTyVarTyAtLevel</span></a></span></span><span> </span><span id="local-6989586621681077858"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077858"><span class="hs-identifier hs-var">tc_lvl</span></a></span></span><span> </span><span id="local-6989586621681077857"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077857"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-1155"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077856"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077856"><span class="hs-identifier hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcM TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcMType.html#newTauTvDetailsAtLevel"><span class="hs-identifier hs-var">newTauTvDetailsAtLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077858"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span>
</span><span id="line-1156"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077855"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077855"><span class="hs-identifier hs-var">name</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastString -&gt; TcM Name
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarName"><span class="hs-identifier hs-var">newMetaTyVarName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;p&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1157"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077855"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077857"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077856"><span class="hs-identifier hs-var">details</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1158"></span><span>
</span><span id="line-1159"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
          Finding variables to quantify over
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-1164"></span><span>
</span><span id="line-1165"></span><span class="hs-comment">{- Note [Dependent type variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Haskell type inference we quantify over type variables; but we only
quantify over /kind/ variables when -XPolyKinds is on.  Without -XPolyKinds
we default the kind variables to *.

So, to support this defaulting, and only for that reason, when
collecting the free vars of a type (in candidateQTyVarsOfType and friends),
prior to quantifying, we must keep the type and kind variables separate.

But what does that mean in a system where kind variables /are/ type
variables? It's a fairly arbitrary distinction based on how the
variables appear:

  - &quot;Kind variables&quot; appear in the kind of some other free variable
    or in the kind of a locally quantified type variable
    (forall (a :: kappa). ...) or in the kind of a coercion
    (a |&gt; (co :: kappa1 ~ kappa2)).

     These are the ones we default to * if -XPolyKinds is off

  - &quot;Type variables&quot; are all free vars that are not kind variables

E.g.  In the type    T k (a::k)
      'k' is a kind variable, because it occurs in the kind of 'a',
          even though it also appears at &quot;top level&quot; of the type
      'a' is a type variable, because it doesn't

We gather these variables using a CandidatesQTvs record:
  DV { dv_kvs: Variables free in the kind of a free type variable
               or of a forall-bound type variable
     , dv_tvs: Variables syntactically free in the type }

So:  dv_kvs            are the kind variables of the type
     (dv_tvs - dv_kvs) are the type variable of the type

Note that

* A variable can occur in both.
      T k (x::k)    The first occurrence of k makes it
                    show up in dv_tvs, the second in dv_kvs

* We include any coercion variables in the &quot;dependent&quot;,
  &quot;kind-variable&quot; set because we never quantify over them.

* The &quot;kind variables&quot; might depend on each other; e.g
     (k1 :: k2), (k2 :: *)
  The &quot;type variables&quot; do not depend on each other; if
  one did, it'd be classified as a kind variable!

Note [CandidatesQTvs determinism and order]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Determinism: when we quantify over type variables we decide the
  order in which they appear in the final type. Because the order of
  type variables in the type can end up in the interface file and
  affects some optimizations like worker-wrapper, we want this order to
  be deterministic.

  To achieve that we use deterministic sets of variables that can be
  converted to lists in a deterministic order. For more information
  about deterministic sets see Note [Deterministic UniqFM] in GHC.Types.Unique.DFM.

* Order: as well as being deterministic, we use an
  accumulating-parameter style for candidateQTyVarsOfType so that we
  add variables one at a time, left to right.  That means we tend to
  produce the variables in left-to-right order.  This is just to make
  it bit more predictable for the programmer.

Note [Naughty quantification candidates]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider (#14880, dependent/should_compile/T14880-2), suppose
we are trying to generalise this type:

  forall arg. ... (alpha[tau]:arg) ...

We have a metavariable alpha whose kind mentions a skolem variable
bound inside the very type we are generalising.
This can arise while type-checking a user-written type signature
(see the test case for the full code).

We cannot generalise over alpha!  That would produce a type like
  forall {a :: arg}. forall arg. ...blah...
The fact that alpha's kind mentions arg renders it completely
ineligible for generalisation.

However, we are not going to learn any new constraints on alpha,
because its kind isn't even in scope in the outer context (but see Wrinkle).
So alpha is entirely unconstrained.

What then should we do with alpha?  During generalization, every
metavariable is either (A) promoted, (B) generalized, or (C) zapped
(according to Note [Recipe for checking a signature] in GHC.Tc.Gen.HsType).

 * We can't generalise it.
 * We can't promote it, because its kind prevents that
 * We can't simply leave it be, because this type is about to
   go into the typing environment (as the type of some let-bound
   variable, say), and then chaos erupts when we try to instantiate.

Previously, we zapped it to Any. This worked, but it had the unfortunate
effect of causing Any sometimes to appear in error messages. If this
kind of signature happens, the user probably has made a mistake -- no
one really wants Any in their types. So we now error. This must be
a hard error (failure in the monad) to avoid other messages from mentioning
Any.

We do this eager erroring in candidateQTyVars, which always precedes
generalisation, because at that moment we have a clear picture of what
skolems are in scope within the type itself (e.g. that 'forall arg').

Wrinkle:

We must make absolutely sure that alpha indeed is not
from an outer context. (Otherwise, we might indeed learn more information
about it.) This can be done easily: we just check alpha's TcLevel.
That level must be strictly greater than the ambient TcLevel in order
to treat it as naughty. We say &quot;strictly greater than&quot; because the call to
candidateQTyVars is made outside the bumped TcLevel, as stated in the
comment to candidateQTyVarsOfType. The level check is done in go_tv
in collect_cand_qtvs. Skipping this check caused #16517.

-}</span><span>
</span><span id="line-1287"></span><span>
</span><span id="line-1288"></span><span class="hs-keyword">data</span><span> </span><span id="CandidatesQTvs"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-var">CandidatesQTvs</span></a></span></span><span>
</span><span id="line-1289"></span><span>  </span><span class="hs-comment">-- See Note [Dependent type variables]</span><span>
</span><span id="line-1290"></span><span>  </span><span class="hs-comment">-- See Note [CandidatesQTvs determinism and order]</span><span>
</span><span id="line-1291"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-1292"></span><span>  </span><span class="hs-comment">-- Invariants:</span><span>
</span><span id="line-1293"></span><span>  </span><span class="hs-comment">--   * All variables are fully zonked, including their kinds</span><span>
</span><span id="line-1294"></span><span>  </span><span class="hs-comment">--   * All variables are at a level greater than the ambient level</span><span>
</span><span id="line-1295"></span><span>  </span><span class="hs-comment">--     See Note [Use level numbers for quantification]</span><span>
</span><span id="line-1296"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-1297"></span><span>  </span><span class="hs-comment">-- This *can* contain skolems. For example, in `data X k :: k -&gt; Type`</span><span>
</span><span id="line-1298"></span><span>  </span><span class="hs-comment">-- we need to know that the k is a dependent variable. This is done</span><span>
</span><span id="line-1299"></span><span>  </span><span class="hs-comment">-- by collecting the candidates in the kind after skolemising. It also</span><span>
</span><span id="line-1300"></span><span>  </span><span class="hs-comment">-- comes up when generalizing a associated type instance, where instance</span><span>
</span><span id="line-1301"></span><span>  </span><span class="hs-comment">-- variables are skolems. (Recall that associated type instances are generalized</span><span>
</span><span id="line-1302"></span><span>  </span><span class="hs-comment">-- independently from their enclosing class instance, and the associated</span><span>
</span><span id="line-1303"></span><span>  </span><span class="hs-comment">-- type instance may be generalized by more, fewer, or different variables</span><span>
</span><span id="line-1304"></span><span>  </span><span class="hs-comment">-- than the class instance.)</span><span>
</span><span id="line-1305"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-1306"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="DV"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-var">DV</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="dv_kvs"><span class="annot"><span class="annottext">CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var hs-var">dv_kvs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DTyVarSet"><span class="hs-identifier hs-type">DTyVarSet</span></a></span><span>    </span><span class="hs-comment">-- &quot;kind&quot; metavariables (dependent)</span><span>
</span><span id="line-1307"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="dv_tvs"><span class="annot"><span class="annottext">CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var hs-var">dv_tvs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DTyVarSet"><span class="hs-identifier hs-type">DTyVarSet</span></a></span><span>    </span><span class="hs-comment">-- &quot;type&quot; metavariables (non-dependent)</span><span>
</span><span id="line-1308"></span><span>         </span><span class="hs-comment">-- A variable may appear in both sets</span><span>
</span><span id="line-1309"></span><span>         </span><span class="hs-comment">-- E.g.   T k (x::k)    The first occurrence of k makes it</span><span>
</span><span id="line-1310"></span><span>         </span><span class="hs-comment">--                      show up in dv_tvs, the second in dv_kvs</span><span>
</span><span id="line-1311"></span><span>         </span><span class="hs-comment">-- See Note [Dependent type variables]</span><span>
</span><span id="line-1312"></span><span>
</span><span id="line-1313"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="dv_cvs"><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var hs-var">dv_cvs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#CoVarSet"><span class="hs-identifier hs-type">CoVarSet</span></a></span><span>
</span><span id="line-1314"></span><span>         </span><span class="hs-comment">-- These are covars. Included only so that we don't repeatedly</span><span>
</span><span id="line-1315"></span><span>         </span><span class="hs-comment">-- look at covars' kinds in accumulator. Not used by quantifyTyVars.</span><span>
</span><span id="line-1316"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-1317"></span><span>
</span><span id="line-1318"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681077845"><span id="local-6989586621681077847"><span class="annot"><a href="../../base/src/GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semi.Semigroup</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1319"></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077843"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077843"><span class="hs-identifier hs-var">kv1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077842"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077842"><span class="hs-identifier hs-var">tv1</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077841"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077841"><span class="hs-identifier hs-var">cv1</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1320"></span><span>     </span><span id="local-6989586621681077840"><span class="annot"><span class="annottext">&lt;&gt; :: CandidatesQTvs -&gt; CandidatesQTvs -&gt; CandidatesQTvs
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">&lt;&gt;</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077839"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077839"><span class="hs-identifier hs-var">kv2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077838"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077838"><span class="hs-identifier hs-var">tv2</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077837"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077837"><span class="hs-identifier hs-var">cv2</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1321"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DV :: DTyVarSet -&gt; DTyVarSet -&gt; TcTyVarSet -&gt; CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077843"><span class="hs-identifier hs-var">kv1</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; DTyVarSet -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#unionDVarSet"><span class="hs-operator hs-var">`unionDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077839"><span class="hs-identifier hs-var">kv2</span></a></span><span>
</span><span id="line-1322"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077842"><span class="hs-identifier hs-var">tv1</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; DTyVarSet -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#unionDVarSet"><span class="hs-operator hs-var">`unionDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077838"><span class="hs-identifier hs-var">tv2</span></a></span><span>
</span><span id="line-1323"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077841"><span class="hs-identifier hs-var">cv1</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TcTyVarSet -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077837"><span class="hs-identifier hs-var">cv2</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1324"></span><span>
</span><span id="line-1325"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681077829"><span class="annot"><a href="../../base/src/GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1326"></span><span>   </span><span id="local-6989586621681077827"><span class="annot"><span class="annottext">mempty :: CandidatesQTvs
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var hs-var hs-var hs-var">mempty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DV :: DTyVarSet -&gt; DTyVarSet -&gt; TcTyVarSet -&gt; CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyDVarSet"><span class="hs-identifier hs-var">emptyDVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyDVarSet"><span class="hs-identifier hs-var">emptyDVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1327"></span><span>   </span><span id="local-6989586621681077823"><span class="annot"><span class="annottext">mappend :: CandidatesQTvs -&gt; CandidatesQTvs -&gt; CandidatesQTvs
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-identifier hs-var hs-var hs-var hs-var">mappend</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; CandidatesQTvs -&gt; CandidatesQTvs
forall a. Semigroup a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">(Semi.&lt;&gt;)</span></a></span><span>
</span><span id="line-1328"></span><span>
</span><span id="line-1329"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681077820"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1330"></span><span>  </span><span id="local-6989586621681077813"><span class="annot"><span class="annottext">ppr :: CandidatesQTvs -&gt; SDoc
</span><a href="#local-6989586621681077813"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077812"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077812"><span class="hs-identifier hs-var">kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077811"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077811"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077810"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077810"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1331"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DV&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; [SDoc] -&gt; SDoc
forall a. (a -&gt; SDoc) -&gt; [a] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#pprWithCommas"><span class="hs-identifier hs-var">pprWithCommas</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dv_kvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077812"><span class="hs-identifier hs-var">kvs</span></a></span><span>
</span><span id="line-1332"></span><span>                                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dv_tvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077811"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-1333"></span><span>                                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dv_cvs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077810"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1334"></span><span>
</span><span id="line-1335"></span><span>
</span><span id="line-1336"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateKindVars"><span class="hs-identifier hs-type">candidateKindVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span>
</span><span id="line-1337"></span><span id="candidateKindVars"><span class="annot"><span class="annottext">candidateKindVars :: CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#candidateKindVars"><span class="hs-identifier hs-var hs-var">candidateKindVars</span></a></span></span><span> </span><span id="local-6989586621681077805"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077805"><span class="hs-identifier hs-var">dvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#dVarSetToVarSet"><span class="hs-identifier hs-var">dVarSetToVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var hs-var">dv_kvs</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077805"><span class="hs-identifier hs-var">dvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1338"></span><span>
</span><span id="line-1339"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#partitionCandidates"><span class="hs-identifier hs-type">partitionCandidates</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1340"></span><span class="hs-comment">-- The selected TyVars are returned as a non-deterministic TyVarSet</span><span>
</span><span id="line-1341"></span><span id="partitionCandidates"><span class="annot"><span class="annottext">partitionCandidates :: CandidatesQTvs -&gt; (TyVar -&gt; Bool) -&gt; (TcTyVarSet, CandidatesQTvs)
</span><a href="GHC.Tc.Utils.TcMType.html#partitionCandidates"><span class="hs-identifier hs-var hs-var">partitionCandidates</span></a></span></span><span> </span><span id="local-6989586621681077803"><span class="annot"><span class="annottext">dvs :: CandidatesQTvs
</span><a href="#local-6989586621681077803"><span class="hs-identifier hs-var">dvs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077802"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077802"><span class="hs-identifier hs-var">kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077801"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077801"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077800"><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="#local-6989586621681077800"><span class="hs-identifier hs-var">pred</span></a></span></span><span>
</span><span id="line-1342"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077799"><span class="hs-identifier hs-var">extracted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077803"><span class="hs-identifier hs-var">dvs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077798"><span class="hs-identifier hs-var">rest_kvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077797"><span class="hs-identifier hs-var">rest_tvs</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1343"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1344"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681077796"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077796"><span class="hs-identifier hs-var">extracted_kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077798"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077798"><span class="hs-identifier hs-var">rest_kvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; Bool) -&gt; DTyVarSet -&gt; (DTyVarSet, DTyVarSet)
</span><a href="GHC.Types.Var.Set.html#partitionDVarSet"><span class="hs-identifier hs-var">partitionDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="#local-6989586621681077800"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077802"><span class="hs-identifier hs-var">kvs</span></a></span><span>
</span><span id="line-1345"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681077794"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077794"><span class="hs-identifier hs-var">extracted_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077797"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077797"><span class="hs-identifier hs-var">rest_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; Bool) -&gt; DTyVarSet -&gt; (DTyVarSet, DTyVarSet)
</span><a href="GHC.Types.Var.Set.html#partitionDVarSet"><span class="hs-identifier hs-var">partitionDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="#local-6989586621681077800"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077801"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-1346"></span><span>    </span><span id="local-6989586621681077799"><span class="annot"><span class="annottext">extracted :: TcTyVarSet
</span><a href="#local-6989586621681077799"><span class="hs-identifier hs-var hs-var">extracted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#dVarSetToVarSet"><span class="hs-identifier hs-var">dVarSetToVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077796"><span class="hs-identifier hs-var">extracted_kvs</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TcTyVarSet -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#dVarSetToVarSet"><span class="hs-identifier hs-var">dVarSetToVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077794"><span class="hs-identifier hs-var">extracted_tvs</span></a></span><span>
</span><span id="line-1347"></span><span>
</span><span id="line-1348"></span><span class="hs-comment">-- | Gathers free variables to use as quantification candidates (in</span><span>
</span><span id="line-1349"></span><span class="hs-comment">-- 'quantifyTyVars'). This might output the same var</span><span>
</span><span id="line-1350"></span><span class="hs-comment">-- in both sets, if it's used in both a type and a kind.</span><span>
</span><span id="line-1351"></span><span class="hs-comment">-- The variables to quantify must have a TcLevel strictly greater than</span><span>
</span><span id="line-1352"></span><span class="hs-comment">-- the ambient level. (See Wrinkle in Note [Naughty quantification candidates])</span><span>
</span><span id="line-1353"></span><span class="hs-comment">-- See Note [CandidatesQTvs determinism and order]</span><span>
</span><span id="line-1354"></span><span class="hs-comment">-- See Note [Dependent type variables]</span><span>
</span><span id="line-1355"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfType"><span class="hs-identifier hs-type">candidateQTyVarsOfType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>       </span><span class="hs-comment">-- not necessarily zonked</span><span>
</span><span id="line-1356"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1357"></span><span id="candidateQTyVarsOfType"><span class="annot"><span class="annottext">candidateQTyVarsOfType :: Kind -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfType"><span class="hs-identifier hs-var hs-var">candidateQTyVarsOfType</span></a></span></span><span> </span><span id="local-6989586621681077793"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077793"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077793"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077793"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1358"></span><span>
</span><span id="line-1359"></span><span class="hs-comment">-- | Like 'candidateQTyVarsOfType', but over a list of types</span><span>
</span><span id="line-1360"></span><span class="hs-comment">-- The variables to quantify must have a TcLevel strictly greater than</span><span>
</span><span id="line-1361"></span><span class="hs-comment">-- the ambient level. (See Wrinkle in Note [Naughty quantification candidates])</span><span>
</span><span id="line-1362"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier hs-type">candidateQTyVarsOfTypes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1363"></span><span id="candidateQTyVarsOfTypes"><span class="annot"><span class="annottext">candidateQTyVarsOfTypes :: [Kind] -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier hs-var hs-var">candidateQTyVarsOfTypes</span></a></span></span><span> </span><span id="local-6989586621681077791"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077791"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Kind] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681077789"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077789"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621681077788"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077788"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077788"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077789"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077788"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1364"></span><span>                                     </span><span class="annot"><span class="annottext">CandidatesQTvs
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077791"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-1365"></span><span>
</span><span id="line-1366"></span><span class="hs-comment">-- | Like 'candidateQTyVarsOfType', but consider every free variable</span><span>
</span><span id="line-1367"></span><span class="hs-comment">-- to be dependent. This is appropriate when generalizing a *kind*,</span><span>
</span><span id="line-1368"></span><span class="hs-comment">-- instead of a type. (That way, -XNoPolyKinds will default the variables</span><span>
</span><span id="line-1369"></span><span class="hs-comment">-- to Type.)</span><span>
</span><span id="line-1370"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfKind"><span class="hs-identifier hs-type">candidateQTyVarsOfKind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span>       </span><span class="hs-comment">-- Not necessarily zonked</span><span>
</span><span id="line-1371"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1372"></span><span id="candidateQTyVarsOfKind"><span class="annot"><span class="annottext">candidateQTyVarsOfKind :: Kind -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfKind"><span class="hs-identifier hs-var hs-var">candidateQTyVarsOfKind</span></a></span></span><span> </span><span id="local-6989586621681077787"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077787"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077787"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077787"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1373"></span><span>
</span><span id="line-1374"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfKinds"><span class="hs-identifier hs-type">candidateQTyVarsOfKinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- Not necessarily zonked</span><span>
</span><span id="line-1375"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1376"></span><span id="candidateQTyVarsOfKinds"><span class="annot"><span class="annottext">candidateQTyVarsOfKinds :: [Kind] -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfKinds"><span class="hs-identifier hs-var hs-var">candidateQTyVarsOfKinds</span></a></span></span><span> </span><span id="local-6989586621681077786"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077786"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Kind] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Control.Monad.html#foldM"><span class="hs-identifier hs-var">foldM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681077784"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077784"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621681077783"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077783"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077783"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077784"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077783"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1377"></span><span>                                    </span><span class="annot"><span class="annottext">CandidatesQTvs
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077786"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-1378"></span><span>
</span><span id="line-1379"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#delCandidates"><span class="hs-identifier hs-type">delCandidates</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1380"></span><span id="delCandidates"><span class="annot"><span class="annottext">delCandidates :: CandidatesQTvs -&gt; [TyVar] -&gt; CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#delCandidates"><span class="hs-identifier hs-var hs-var">delCandidates</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077781"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077781"><span class="hs-identifier hs-var">kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077780"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077780"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077779"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077779"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077778"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077778"><span class="hs-identifier hs-var">vars</span></a></span></span><span>
</span><span id="line-1381"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DV :: DTyVarSet -&gt; DTyVarSet -&gt; TcTyVarSet -&gt; CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077781"><span class="hs-identifier hs-var">kvs</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TyVar] -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#delDVarSetList"><span class="hs-operator hs-var">`delDVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077778"><span class="hs-identifier hs-var">vars</span></a></span><span>
</span><span id="line-1382"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077780"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TyVar] -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#delDVarSetList"><span class="hs-operator hs-var">`delDVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077778"><span class="hs-identifier hs-var">vars</span></a></span><span>
</span><span id="line-1383"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077779"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; [TyVar] -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#delVarSetList"><span class="hs-operator hs-var">`delVarSetList`</span></a></span><span>  </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077778"><span class="hs-identifier hs-var">vars</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1384"></span><span>
</span><span id="line-1385"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-type">collect_cand_qtvs</span></a></span><span>
</span><span id="line-1386"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>          </span><span class="hs-comment">-- original type that we started recurring into; for errors</span><span>
</span><span id="line-1387"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>            </span><span class="hs-comment">-- True &lt;=&gt; consider every fv in Type to be dependent</span><span>
</span><span id="line-1388"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>          </span><span class="hs-comment">-- Bound variables (locals only)</span><span>
</span><span id="line-1389"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>  </span><span class="hs-comment">-- Accumulating parameter</span><span>
</span><span id="line-1390"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>            </span><span class="hs-comment">-- Not necessarily zonked</span><span>
</span><span id="line-1391"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1392"></span><span>
</span><span id="line-1393"></span><span class="hs-comment">-- Key points:</span><span>
</span><span id="line-1394"></span><span class="hs-comment">--   * Looks through meta-tyvars as it goes;</span><span>
</span><span id="line-1395"></span><span class="hs-comment">--     no need to zonk in advance</span><span>
</span><span id="line-1396"></span><span class="hs-comment">--</span><span>
</span><span id="line-1397"></span><span class="hs-comment">--   * Needs to be monadic anyway, because it handles naughty</span><span>
</span><span id="line-1398"></span><span class="hs-comment">--     quantification; see Note [Naughty quantification candidates]</span><span>
</span><span id="line-1399"></span><span class="hs-comment">--</span><span>
</span><span id="line-1400"></span><span class="hs-comment">--   * Returns fully-zonked CandidateQTvs, including their kinds</span><span>
</span><span id="line-1401"></span><span class="hs-comment">--     so that subsequent dependency analysis (to build a well</span><span>
</span><span id="line-1402"></span><span class="hs-comment">--     scoped telescope) works correctly</span><span>
</span><span id="line-1403"></span><span>
</span><span id="line-1404"></span><span id="collect_cand_qtvs"><span class="annot"><span class="annottext">collect_cand_qtvs :: Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var hs-var">collect_cand_qtvs</span></a></span></span><span> </span><span id="local-6989586621681077774"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span> </span><span id="local-6989586621681077773"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077773"><span class="hs-identifier hs-var">is_dep</span></a></span></span><span> </span><span id="local-6989586621681077772"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span></span><span> </span><span id="local-6989586621681077771"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077771"><span class="hs-identifier hs-var">dvs</span></a></span></span><span> </span><span id="local-6989586621681077770"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077770"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-1405"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077771"><span class="hs-identifier hs-var">dvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077770"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1406"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1407"></span><span>    </span><span id="local-6989586621681077768"><span class="annot"><span class="annottext">is_bound :: TyVar -&gt; Bool
</span><a href="#local-6989586621681077768"><span class="hs-identifier hs-var hs-var">is_bound</span></a></span></span><span> </span><span id="local-6989586621681077767"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077767"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077767"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span>
</span><span id="line-1408"></span><span>
</span><span id="line-1409"></span><span>    </span><span class="hs-comment">-----------------</span><span>
</span><span id="line-1410"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1411"></span><span>    </span><span class="hs-comment">-- Uses accumulating-parameter style</span><span>
</span><span id="line-1412"></span><span>    </span><span id="local-6989586621681077769"><span class="annot"><span class="annottext">go :: CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681077765"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077765"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppTy"><span class="hs-identifier hs-type">AppTy</span></a></span><span> </span><span id="local-6989586621681077763"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077763"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681077762"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077762"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Kind] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077765"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077763"><span class="hs-identifier hs-var">t1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077762"><span class="hs-identifier hs-var">t2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1413"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077761"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077761"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConApp"><span class="hs-identifier hs-type">TyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077759"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077759"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Kind] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077761"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077759"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-1414"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077758"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077758"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077756"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077756"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681077755"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077755"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span id="local-6989586621681077754"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077754"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Kind] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077758"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077756"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077755"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077754"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1415"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077753"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077753"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LitTy"><span class="hs-identifier hs-type">LitTy</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077753"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1416"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077751"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077751"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CastTy"><span class="hs-identifier hs-type">CastTy</span></a></span><span> </span><span id="local-6989586621681077749"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077749"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681077748"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077748"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681077747"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077747"><span class="hs-identifier hs-var">dv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077751"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077749"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1417"></span><span>                                 </span><span class="annot"><span class="annottext">Kind
-&gt; TcTyVarSet -&gt; CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs_co"><span class="hs-identifier hs-var">collect_cand_qtvs_co</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077747"><span class="hs-identifier hs-var">dv1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077748"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1418"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077745"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077745"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionTy"><span class="hs-identifier hs-type">CoercionTy</span></a></span><span> </span><span id="local-6989586621681077743"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077743"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; TcTyVarSet -&gt; CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs_co"><span class="hs-identifier hs-var">collect_cand_qtvs_co</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077745"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077743"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1419"></span><span>
</span><span id="line-1420"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077742"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077742"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyVarTy"><span class="hs-identifier hs-type">TyVarTy</span></a></span><span> </span><span id="local-6989586621681077740"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077740"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1421"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="#local-6989586621681077768"><span class="hs-identifier hs-var">is_bound</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077740"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077742"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1422"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077739"><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681077739"><span class="hs-identifier hs-var">m_contents</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM (Maybe Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#isFilledMetaTyVar_maybe"><span class="hs-identifier hs-var">isFilledMetaTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077740"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1423"></span><span>                         </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681077739"><span class="hs-identifier hs-var">m_contents</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1424"></span><span>                             </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681077738"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077738"><span class="hs-identifier hs-var">ind_ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Kind -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077742"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077738"><span class="hs-identifier hs-var">ind_ty</span></a></span><span>
</span><span id="line-1425"></span><span>                             </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TyVar -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077737"><span class="hs-identifier hs-var">go_tv</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077742"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077740"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1426"></span><span>
</span><span id="line-1427"></span><span>    </span><span class="annot"><a href="#local-6989586621681077769"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681077736"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077736"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681077733"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077733"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077732"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077732"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1428"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077731"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077731"><span class="hs-identifier hs-var">dv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077736"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077733"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1429"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077773"><span class="hs-identifier hs-var">is_dep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TyVar -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077733"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077731"><span class="hs-identifier hs-var">dv1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077732"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1430"></span><span>
</span><span id="line-1431"></span><span>    </span><span class="hs-comment">-----------------</span><span>
</span><span id="line-1432"></span><span>    </span><span id="local-6989586621681077737"><span class="annot"><span class="annottext">go_tv :: CandidatesQTvs -&gt; TyVar -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077737"><span class="hs-identifier hs-var hs-var">go_tv</span></a></span></span><span> </span><span id="local-6989586621681077720"><span class="annot"><span class="annottext">dv :: CandidatesQTvs
</span><a href="#local-6989586621681077720"><span class="hs-identifier hs-var">dv</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077719"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077719"><span class="hs-identifier hs-var">kvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077718"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077718"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077717"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1433"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; DTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemDVarSet"><span class="hs-operator hs-var">`elemDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077719"><span class="hs-identifier hs-var">kvs</span></a></span><span>
</span><span id="line-1434"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077720"><span class="hs-identifier hs-var">dv</span></a></span><span>  </span><span class="hs-comment">-- We have met this tyvar already</span><span>
</span><span id="line-1435"></span><span>
</span><span id="line-1436"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077773"><span class="hs-identifier hs-var">is_dep</span></a></span><span>
</span><span id="line-1437"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; DTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemDVarSet"><span class="hs-operator hs-var">`elemDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077718"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-1438"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077720"><span class="hs-identifier hs-var">dv</span></a></span><span>  </span><span class="hs-comment">-- We have met this tyvar already</span><span>
</span><span id="line-1439"></span><span>
</span><span id="line-1440"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1441"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077715"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077715"><span class="hs-identifier hs-var">tv_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1442"></span><span>                 </span><span class="hs-comment">-- This zonk is annoying, but it is necessary, both to</span><span>
</span><span id="line-1443"></span><span>                 </span><span class="hs-comment">-- ensure that the collected candidates have zonked kinds</span><span>
</span><span id="line-1444"></span><span>                 </span><span class="hs-comment">-- (#15795) and to make the naughty check</span><span>
</span><span id="line-1445"></span><span>                 </span><span class="hs-comment">-- (which comes next) works correctly</span><span>
</span><span id="line-1446"></span><span>
</span><span id="line-1447"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077714"><span class="annot"><span class="annottext">tv_kind_vars :: TcTyVarSet
</span><a href="#local-6989586621681077714"><span class="hs-identifier hs-var hs-var">tv_kind_vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcTyVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077715"><span class="hs-identifier hs-var">tv_kind</span></a></span><span>
</span><span id="line-1448"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077712"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077712"><span class="hs-identifier hs-var">cur_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-1449"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">TyVar -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#tcTyVarLevel"><span class="hs-identifier hs-var">tcTyVarLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077712"><span class="hs-identifier hs-var">cur_lvl</span></a></span><span>
</span><span id="line-1450"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077720"><span class="hs-identifier hs-var">dv</span></a></span><span>   </span><span class="hs-comment">-- this variable is from an outer context; skip</span><span>
</span><span id="line-1451"></span><span>                               </span><span class="hs-comment">-- See Note [Use level numbers ofor quantification]</span><span>
</span><span id="line-1452"></span><span>
</span><span id="line-1453"></span><span>                </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TcTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#intersectsVarSet"><span class="hs-identifier hs-var">intersectsVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077714"><span class="hs-identifier hs-var">tv_kind_vars</span></a></span><span>
</span><span id="line-1454"></span><span>                   </span><span class="hs-comment">-- the tyvar must not be from an outer context, but we have</span><span>
</span><span id="line-1455"></span><span>                   </span><span class="hs-comment">-- already checked for this.</span><span>
</span><span id="line-1456"></span><span>                   </span><span class="hs-comment">-- See Note [Naughty quantification candidates]</span><span>
</span><span id="line-1457"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Naughty quantifier&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1458"></span><span>                          </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077715"><span class="hs-identifier hs-var">tv_kind</span></a></span><span>
</span><span id="line-1459"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;bound:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet -&gt; [TyVar]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1460"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fvs:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet -&gt; [TyVar]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077714"><span class="hs-identifier hs-var">tv_kind_vars</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1461"></span><span>
</span><span id="line-1462"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077708"><span class="annot"><span class="annottext">escapees :: TcTyVarSet
</span><a href="#local-6989586621681077708"><span class="hs-identifier hs-var hs-var">escapees</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TcTyVarSet -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#intersectVarSet"><span class="hs-identifier hs-var">intersectVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077714"><span class="hs-identifier hs-var">tv_kind_vars</span></a></span><span>
</span><span id="line-1463"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TyVar -&gt; TcTyVarSet -&gt; TcM CandidatesQTvs
forall a. Kind -&gt; TyVar -&gt; TcTyVarSet -&gt; TcM a
</span><a href="GHC.Tc.Utils.TcMType.html#naughtyQuantification"><span class="hs-identifier hs-var">naughtyQuantification</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077708"><span class="hs-identifier hs-var">escapees</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1464"></span><span>
</span><span id="line-1465"></span><span>                </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1466"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077705"><span class="annot"><span class="annottext">tv' :: TyVar
</span><a href="#local-6989586621681077705"><span class="hs-identifier hs-var hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077717"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-operator hs-var">`setTyVarKind`</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077715"><span class="hs-identifier hs-var">tv_kind</span></a></span><span>
</span><span id="line-1467"></span><span>                            </span><span id="local-6989586621681077703"><span class="annot"><span class="annottext">dv' :: CandidatesQTvs
</span><a href="#local-6989586621681077703"><span class="hs-identifier hs-var hs-var">dv'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077773"><span class="hs-identifier hs-var">is_dep</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077720"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077719"><span class="hs-identifier hs-var">kvs</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; TyVar -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#extendDVarSet"><span class="hs-operator hs-var">`extendDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077705"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1468"></span><span>                                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077720"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077718"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; TyVar -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#extendDVarSet"><span class="hs-operator hs-var">`extendDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077705"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1469"></span><span>                                </span><span class="hs-comment">-- See Note [Order of accumulation]</span><span>
</span><span id="line-1470"></span><span>
</span><span id="line-1471"></span><span>                        </span><span class="hs-comment">-- See Note [Recurring into kinds for candidateQTyVars]</span><span>
</span><span id="line-1472"></span><span>                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077774"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077772"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077703"><span class="hs-identifier hs-var">dv'</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077715"><span class="hs-identifier hs-var">tv_kind</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1473"></span><span>
</span><span id="line-1474"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs_co"><span class="hs-identifier hs-type">collect_cand_qtvs_co</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-comment">-- original type at top of recursion; for errors</span><span>
</span><span id="line-1475"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span> </span><span class="hs-comment">-- bound variables</span><span>
</span><span id="line-1476"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-1477"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1478"></span><span id="collect_cand_qtvs_co"><span class="annot"><span class="annottext">collect_cand_qtvs_co :: Kind
-&gt; TcTyVarSet -&gt; CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs_co"><span class="hs-identifier hs-var hs-var">collect_cand_qtvs_co</span></a></span></span><span> </span><span id="local-6989586621681077701"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span> </span><span id="local-6989586621681077700"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span>
</span><span id="line-1479"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1480"></span><span>    </span><span id="local-6989586621681077699"><span class="annot"><span class="annottext">go_co :: CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var hs-var">go_co</span></a></span></span><span> </span><span id="local-6989586621681077676"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077676"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Refl"><span class="hs-identifier hs-type">Refl</span></a></span><span> </span><span id="local-6989586621681077674"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077674"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077676"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077674"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1481"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077673"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077673"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#GRefl"><span class="hs-identifier hs-type">GRefl</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077671"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077671"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681077670"><span class="annot"><span class="annottext">MCoercionN
</span><a href="#local-6989586621681077670"><span class="hs-identifier hs-var">mco</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681077669"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077669"><span class="hs-identifier hs-var">dv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077673"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077671"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1482"></span><span>                                        </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; MCoercionN -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077668"><span class="hs-identifier hs-var">go_mco</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077669"><span class="hs-identifier hs-var">dv1</span></a></span><span> </span><span class="annot"><span class="annottext">MCoercionN
</span><a href="#local-6989586621681077670"><span class="hs-identifier hs-var">mco</span></a></span><span>
</span><span id="line-1483"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077667"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077667"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyConAppCo"><span class="hs-identifier hs-type">TyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077665"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681077665"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077667"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681077665"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-1484"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077664"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077664"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AppCo"><span class="hs-identifier hs-type">AppCo</span></a></span><span> </span><span id="local-6989586621681077662"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077662"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621681077661"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077661"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077664"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077662"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077661"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1485"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077660"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077660"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunCo"><span class="hs-identifier hs-type">FunCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077658"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077658"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681077657"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077657"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621681077656"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077656"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077660"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077658"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077657"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077656"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1486"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077655"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077655"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AxiomInstCo"><span class="hs-identifier hs-type">AxiomInstCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Branched
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077653"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681077653"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077655"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681077653"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-1487"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077652"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077652"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AxiomRuleCo"><span class="hs-identifier hs-type">AxiomRuleCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiomRule
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077650"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681077650"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077652"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681077650"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-1488"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077649"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077649"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#UnivCo"><span class="hs-identifier hs-type">UnivCo</span></a></span><span> </span><span id="local-6989586621681077647"><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621681077647"><span class="hs-identifier hs-var">prov</span></a></span></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077646"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077646"><span class="hs-identifier hs-var">t1</span></a></span></span><span> </span><span id="local-6989586621681077645"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077645"><span class="hs-identifier hs-var">t2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681077644"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077644"><span class="hs-identifier hs-var">dv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; UnivCoProvenance -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077643"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077649"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="#local-6989586621681077647"><span class="hs-identifier hs-var">prov</span></a></span><span>
</span><span id="line-1489"></span><span>                                        </span><span id="local-6989586621681077642"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077642"><span class="hs-identifier hs-var">dv2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077644"><span class="hs-identifier hs-var">dv1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077646"><span class="hs-identifier hs-var">t1</span></a></span><span>
</span><span id="line-1490"></span><span>                                        </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077642"><span class="hs-identifier hs-var">dv2</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077645"><span class="hs-identifier hs-var">t2</span></a></span><span>
</span><span id="line-1491"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077641"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077641"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SymCo"><span class="hs-identifier hs-type">SymCo</span></a></span><span> </span><span id="local-6989586621681077639"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077639"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077641"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077639"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1492"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077638"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077638"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TransCo"><span class="hs-identifier hs-type">TransCo</span></a></span><span> </span><span id="local-6989586621681077636"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077636"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621681077635"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077635"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077638"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077636"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077635"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1493"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077634"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077634"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#NthCo"><span class="hs-identifier hs-type">NthCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077632"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077632"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077634"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077632"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1494"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077631"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077631"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#LRCo"><span class="hs-identifier hs-type">LRCo</span></a></span><span> </span><span class="annot"><span class="annottext">LeftOrRight
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077629"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077629"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077631"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077629"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1495"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077628"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077628"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#InstCo"><span class="hs-identifier hs-type">InstCo</span></a></span><span> </span><span id="local-6989586621681077626"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077626"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span id="local-6989586621681077625"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077625"><span class="hs-identifier hs-var">co2</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs)
-&gt; CandidatesQTvs -&gt; [Coercion] -&gt; TcM CandidatesQTvs
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077628"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077626"><span class="hs-identifier hs-var">co1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077625"><span class="hs-identifier hs-var">co2</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1496"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077624"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077624"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#KindCo"><span class="hs-identifier hs-type">KindCo</span></a></span><span> </span><span id="local-6989586621681077622"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077622"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077624"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077622"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1497"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077621"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077621"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#SubCo"><span class="hs-identifier hs-type">SubCo</span></a></span><span> </span><span id="local-6989586621681077619"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077619"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077621"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077619"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1498"></span><span>
</span><span id="line-1499"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077618"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077618"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#HoleCo"><span class="hs-identifier hs-type">HoleCo</span></a></span><span> </span><span id="local-6989586621681077617"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681077617"><span class="hs-identifier hs-var">hole</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1500"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681077616"><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="#local-6989586621681077616"><span class="hs-identifier hs-var">m_co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
</span><a href="GHC.Tc.Utils.TcMType.html#unpackCoercionHole_maybe"><span class="hs-identifier hs-var">unpackCoercionHole_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681077617"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-1501"></span><span>           </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="#local-6989586621681077616"><span class="hs-identifier hs-var">m_co</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1502"></span><span>             </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681077615"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077615"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077618"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077615"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1503"></span><span>             </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TyVar -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077614"><span class="hs-identifier hs-var">go_cv</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077618"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionHole -&gt; TyVar
</span><a href="GHC.Core.TyCo.Rep.html#coHoleCoVar"><span class="hs-identifier hs-var">coHoleCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681077617"><span class="hs-identifier hs-var">hole</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1504"></span><span>
</span><span id="line-1505"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077612"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077612"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoVarCo"><span class="hs-identifier hs-type">CoVarCo</span></a></span><span> </span><span id="local-6989586621681077610"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077610"><span class="hs-identifier hs-var">cv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TyVar -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077614"><span class="hs-identifier hs-var">go_cv</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077612"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077610"><span class="hs-identifier hs-var">cv</span></a></span><span>
</span><span id="line-1506"></span><span>
</span><span id="line-1507"></span><span>    </span><span class="annot"><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span id="local-6989586621681077609"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077609"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllCo"><span class="hs-identifier hs-type">ForAllCo</span></a></span><span> </span><span id="local-6989586621681077607"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077607"><span class="hs-identifier hs-var">tcv</span></a></span></span><span> </span><span id="local-6989586621681077606"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077606"><span class="hs-identifier hs-var">kind_co</span></a></span></span><span> </span><span id="local-6989586621681077605"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077605"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1508"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077604"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077604"><span class="hs-identifier hs-var">dv1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077609"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077606"><span class="hs-identifier hs-var">kind_co</span></a></span><span>
</span><span id="line-1509"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; TcTyVarSet -&gt; CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs_co"><span class="hs-identifier hs-var">collect_cand_qtvs_co</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TyVar -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077607"><span class="hs-identifier hs-var">tcv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077604"><span class="hs-identifier hs-var">dv1</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077605"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1510"></span><span>
</span><span id="line-1511"></span><span>    </span><span id="local-6989586621681077668"><span class="annot"><span class="annottext">go_mco :: CandidatesQTvs -&gt; MCoercionN -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077668"><span class="hs-identifier hs-var hs-var">go_mco</span></a></span></span><span> </span><span id="local-6989586621681077603"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077603"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="annot"><span class="annottext">MCoercionN
</span><a href="GHC.Core.TyCo.Rep.html#MRefl"><span class="hs-identifier hs-var">MRefl</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077603"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1512"></span><span>    </span><span class="annot"><a href="#local-6989586621681077668"><span class="hs-identifier hs-var">go_mco</span></a></span><span> </span><span id="local-6989586621681077601"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077601"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#MCo"><span class="hs-identifier hs-type">MCo</span></a></span><span> </span><span id="local-6989586621681077599"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077599"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077601"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077599"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1513"></span><span>
</span><span id="line-1514"></span><span>    </span><span id="local-6989586621681077643"><span class="annot"><span class="annottext">go_prov :: CandidatesQTvs -&gt; UnivCoProvenance -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077643"><span class="hs-identifier hs-var hs-var">go_prov</span></a></span></span><span> </span><span id="local-6989586621681077598"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077598"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PhantomProv"><span class="hs-identifier hs-type">PhantomProv</span></a></span><span> </span><span id="local-6989586621681077596"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077596"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077598"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077596"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1515"></span><span>    </span><span class="annot"><a href="#local-6989586621681077643"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span id="local-6989586621681077595"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077595"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ProofIrrelProv"><span class="hs-identifier hs-type">ProofIrrelProv</span></a></span><span> </span><span id="local-6989586621681077593"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077593"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; Coercion -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077699"><span class="hs-identifier hs-var">go_co</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077595"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077593"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1516"></span><span>    </span><span class="annot"><a href="#local-6989586621681077643"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span id="local-6989586621681077592"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077592"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PluginProv"><span class="hs-identifier hs-type">PluginProv</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077592"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1517"></span><span>    </span><span class="annot"><a href="#local-6989586621681077643"><span class="hs-identifier hs-var">go_prov</span></a></span><span> </span><span id="local-6989586621681077590"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077590"><span class="hs-identifier hs-var">dv</span></a></span></span><span> </span><span class="annot"><span class="annottext">UnivCoProvenance
</span><a href="GHC.Core.TyCo.Rep.html#CorePrepProv"><span class="hs-identifier hs-var">CorePrepProv</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077590"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1518"></span><span>
</span><span id="line-1519"></span><span>    </span><span class="annot"><a href="#local-6989586621681077614"><span class="hs-identifier hs-type">go_cv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>
</span><span id="line-1520"></span><span>    </span><span id="local-6989586621681077614"><span class="annot"><span class="annottext">go_cv :: CandidatesQTvs -&gt; TyVar -&gt; TcM CandidatesQTvs
</span><a href="#local-6989586621681077614"><span class="hs-identifier hs-var hs-var">go_cv</span></a></span></span><span> </span><span id="local-6989586621681077588"><span class="annot"><span class="annottext">dv :: CandidatesQTvs
</span><a href="#local-6989586621681077588"><span class="hs-identifier hs-var">dv</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: CandidatesQTvs -&gt; TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077587"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077587"><span class="hs-identifier hs-var">cvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077586"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077586"><span class="hs-identifier hs-var">cv</span></a></span></span><span>
</span><span id="line-1521"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="#local-6989586621681077585"><span class="hs-identifier hs-var">is_bound</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077586"><span class="hs-identifier hs-var">cv</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077588"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1522"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077586"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077587"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM CandidatesQTvs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077588"><span class="hs-identifier hs-var">dv</span></a></span><span>
</span><span id="line-1523"></span><span>
</span><span id="line-1524"></span><span>        </span><span class="hs-comment">-- See Note [Recurring into kinds for candidateQTyVars]</span><span>
</span><span id="line-1525"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; Bool
-&gt; TcTyVarSet
-&gt; CandidatesQTvs
-&gt; Kind
-&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#collect_cand_qtvs"><span class="hs-identifier hs-var">collect_cand_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077701"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span>
</span><span id="line-1526"></span><span>                                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077588"><span class="hs-identifier hs-var">dv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_cvs :: TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_cvs"><span class="hs-identifier hs-var">dv_cvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077587"><span class="hs-identifier hs-var">cvs</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; TyVar -&gt; TcTyVarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-operator hs-var">`extendVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077586"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1527"></span><span>                                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077586"><span class="hs-identifier hs-var">cv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1528"></span><span>
</span><span id="line-1529"></span><span>    </span><span id="local-6989586621681077585"><span class="annot"><span class="annottext">is_bound :: TyVar -&gt; Bool
</span><a href="#local-6989586621681077585"><span class="hs-identifier hs-var hs-var">is_bound</span></a></span></span><span> </span><span id="local-6989586621681077583"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077583"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077583"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077700"><span class="hs-identifier hs-var">bound</span></a></span><span>
</span><span id="line-1530"></span><span>
</span><span id="line-1531"></span><span class="hs-comment">{- Note [Order of accumulation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You might be tempted (like I was) to use unitDVarSet and mappend
rather than extendDVarSet.  However, the union algorithm for
deterministic sets depends on (roughly) the size of the sets. The
elements from the smaller set end up to the right of the elements from
the larger one. When sets are equal, the left-hand argument to
`mappend` goes to the right of the right-hand argument.

In our case, if we use unitDVarSet and mappend, we learn that the free
variables of (a -&gt; b -&gt; c -&gt; d) are [b, a, c, d], and we then quantify
over them in that order. (The a comes after the b because we union the
singleton sets as ({a} `mappend` {b}), producing {b, a}. Thereafter,
the size criterion works to our advantage.) This is just annoying to
users, so I use `extendDVarSet`, which unambiguously puts the new
element to the right.

Note that the unitDVarSet/mappend implementation would not be wrong
against any specification -- just suboptimal and confounding to users.

Note [Recurring into kinds for candidateQTyVars]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
First, read Note [Closing over free variable kinds] in GHC.Core.TyCo.FVs, paying
attention to the end of the Note about using an empty bound set when
traversing a variable's kind.

That Note concludes with the recommendation that we empty out the bound
set when recurring into the kind of a type variable. Yet, we do not do
this here. I have two tasks in order to convince you that this code is
right. First, I must show why it is safe to ignore the reasoning in that
Note. Then, I must show why is is necessary to contradict the reasoning in
that Note.

Why it is safe: There can be no
shadowing in the candidateQ... functions: they work on the output of
type inference, which is seeded by the renamer and its insistence to
use different Uniques for different variables. (In contrast, the Core
functions work on the output of optimizations, which may introduce
shadowing.) Without shadowing, the problem studied by
Note [Closing over free variable kinds] in GHC.Core.TyCo.FVs cannot happen.

Why it is necessary:
Wiping the bound set would be just plain wrong here. Consider

  forall k1 k2 (a :: k1). Proxy k2 (a |&gt; (hole :: k1 ~# k2))

We really don't want to think k1 and k2 are free here. (It's true that we'll
never be able to fill in `hole`, but we don't want to go off the rails just
because we have an insoluble coercion hole.) So: why is it wrong to wipe
the bound variables here but right in Core? Because the final statement
in Note [Closing over free variable kinds] in GHC.Core.TyCo.FVs is wrong: not
every variable is either free or bound. A variable can be a hole, too!
The reasoning in that Note then breaks down.

And the reasoning applies just as well to free non-hole variables, so we
retain the bound set always.

-}</span><span>
</span><span id="line-1589"></span><span>
</span><span id="line-1590"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
             Quantification
*                                                                      *
************************************************************************

Note [quantifyTyVars]
~~~~~~~~~~~~~~~~~~~~~
quantifyTyVars is given the free vars of a type that we
are about to wrap in a forall.

It takes these free type/kind variables (partitioned into dependent and
non-dependent variables) skolemises metavariables with a TcLevel greater
than the ambient level (see Note [Use level numbers of quantification]).

* This function distinguishes between dependent and non-dependent
  variables only to keep correct defaulting behavior with -XNoPolyKinds.
  With -XPolyKinds, it treats both classes of variables identically.

* quantifyTyVars never quantifies over
    - a coercion variable (or any tv mentioned in the kind of a covar)
    - a runtime-rep variable

Note [Use level numbers for quantification]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The level numbers assigned to metavariables are very useful. Not only
do they track touchability (Note [TcLevel and untouchable type variables]
in GHC.Tc.Utils.TcType), but they also allow us to determine which variables to
generalise. The rule is this:

  When generalising, quantify only metavariables with a TcLevel greater
  than the ambient level.

This works because we bump the level every time we go inside a new
source-level construct. In a traditional generalisation algorithm, we
would gather all free variables that aren't free in an environment.
However, if a variable is in that environment, it will always have a lower
TcLevel: it came from an outer scope. So we can replace the &quot;free in
environment&quot; check with a level-number check.

Here is an example:

  f x = x + (z True)
    where
      z y = x * x

We start by saying (x :: alpha[1]). When inferring the type of z, we'll
quickly discover that z :: alpha[1]. But it would be disastrous to
generalise over alpha in the type of z. So we need to know that alpha
comes from an outer environment. By contrast, the type of y is beta[2],
and we are free to generalise over it. What's the difference between
alpha[1] and beta[2]? Their levels. beta[2] has the right TcLevel for
generalisation, and so we generalise it. alpha[1] does not, and so
we leave it alone.

Note that not *every* variable with a higher level will get generalised,
either due to the monomorphism restriction or other quirks. See, for
example, the code in GHC.Tc.Solver.decideMonoTyVars and in
GHC.Tc.Gen.HsType.kindGeneralizeSome, both of which exclude certain otherwise-eligible
variables from being generalised.

Using level numbers for quantification is implemented in the candidateQTyVars...
functions, by adding only those variables with a level strictly higher than
the ambient level to the set of candidates.

Note [quantifyTyVars determinism]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The results of quantifyTyVars are wrapped in a forall and can end up in the
interface file. One such example is inferred type signatures. They also affect
the results of optimizations, for example worker-wrapper. This means that to
get deterministic builds quantifyTyVars needs to be deterministic.

To achieve this CandidatesQTvs is backed by deterministic sets which allows them
to be later converted to a list in a deterministic order.

For more information about deterministic sets see
Note [Deterministic UniqFM] in GHC.Types.Unique.DFM.
-}</span><span>
</span><span id="line-1668"></span><span>
</span><span id="line-1669"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#quantifyTyVars"><span class="hs-identifier hs-type">quantifyTyVars</span></a></span><span>
</span><span id="line-1670"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#CandidatesQTvs"><span class="hs-identifier hs-type">CandidatesQTvs</span></a></span><span>   </span><span class="hs-comment">-- See Note [Dependent type variables]</span><span>
</span><span id="line-1671"></span><span>                      </span><span class="hs-comment">-- Already zonked</span><span>
</span><span id="line-1672"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1673"></span><span class="hs-comment">-- See Note [quantifyTyVars]</span><span>
</span><span id="line-1674"></span><span class="hs-comment">-- Can be given a mixture of TcTyVars and TyVars, in the case of</span><span>
</span><span id="line-1675"></span><span class="hs-comment">--   associated type declarations. Also accepts covars, but *never* returns any.</span><span>
</span><span id="line-1676"></span><span class="hs-comment">-- According to Note [Use level numbers for quantification] and the</span><span>
</span><span id="line-1677"></span><span class="hs-comment">-- invariants on CandidateQTvs, we do not have to filter out variables</span><span>
</span><span id="line-1678"></span><span class="hs-comment">-- free in the environment here. Just quantify unconditionally, subject</span><span>
</span><span id="line-1679"></span><span class="hs-comment">-- to the restrictions in Note [quantifyTyVars].</span><span>
</span><span id="line-1680"></span><span id="quantifyTyVars"><span class="annot"><span class="annottext">quantifyTyVars :: CandidatesQTvs -&gt; TcM [TyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#quantifyTyVars"><span class="hs-identifier hs-var hs-var">quantifyTyVars</span></a></span></span><span> </span><span id="local-6989586621681077582"><span class="annot"><span class="annottext">dvs :: CandidatesQTvs
</span><a href="#local-6989586621681077582"><span class="hs-identifier hs-var">dvs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#DV"><span class="hs-identifier hs-type">DV</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dv_kvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_kvs"><span class="hs-identifier hs-var">dv_kvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077581"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077581"><span class="hs-identifier hs-var">dep_tkvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dv_tvs :: CandidatesQTvs -&gt; DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#dv_tvs"><span class="hs-identifier hs-var">dv_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077580"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077580"><span class="hs-identifier hs-var">nondep_tkvs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1681"></span><span>       </span><span class="hs-comment">-- short-circuit common case</span><span>
</span><span id="line-1682"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyDVarSet"><span class="hs-identifier hs-var">isEmptyDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077581"><span class="hs-identifier hs-var">dep_tkvs</span></a></span><span>
</span><span id="line-1683"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#isEmptyDVarSet"><span class="hs-identifier hs-var">isEmptyDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077580"><span class="hs-identifier hs-var">nondep_tkvs</span></a></span><span>
</span><span id="line-1684"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;quantifyTyVars has nothing to quantify&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">empty</span></a></span><span>
</span><span id="line-1685"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; TcM [TyVar]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1686"></span><span>
</span><span id="line-1687"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1688"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;quantifyTyVars 1&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681077582"><span class="hs-identifier hs-var">dvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1689"></span><span>
</span><span id="line-1690"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077577"><span class="annot"><span class="annottext">dep_kvs :: [TyVar]
</span><a href="#local-6989586621681077577"><span class="hs-identifier hs-var hs-var">dep_kvs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; [TyVar]
</span><a href="GHC.Core.TyCo.FVs.html#scopedSort"><span class="hs-identifier hs-var">scopedSort</span></a></span><span> </span><span class="annot"><span class="annottext">([TyVar] -&gt; [TyVar]) -&gt; [TyVar] -&gt; [TyVar]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TyVar]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077581"><span class="hs-identifier hs-var">dep_tkvs</span></a></span><span>
</span><span id="line-1691"></span><span>                       </span><span class="hs-comment">-- scopedSort: put the kind variables into</span><span>
</span><span id="line-1692"></span><span>                       </span><span class="hs-comment">--    well-scoped order.</span><span>
</span><span id="line-1693"></span><span>                       </span><span class="hs-comment">--    E.g.  [k, (a::k)] not the other way round</span><span>
</span><span id="line-1694"></span><span>
</span><span id="line-1695"></span><span>             </span><span id="local-6989586621681077574"><span class="annot"><span class="annottext">nondep_tvs :: [TyVar]
</span><a href="#local-6989586621681077574"><span class="hs-identifier hs-var hs-var">nondep_tvs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TyVar]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077580"><span class="hs-identifier hs-var">nondep_tkvs</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; DTyVarSet -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#minusDVarSet"><span class="hs-operator hs-var">`minusDVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077581"><span class="hs-identifier hs-var">dep_tkvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1696"></span><span>                 </span><span class="hs-comment">-- See Note [Dependent type variables]</span><span>
</span><span id="line-1697"></span><span>                 </span><span class="hs-comment">-- The `minus` dep_tkvs removes any kind-level vars</span><span>
</span><span id="line-1698"></span><span>                 </span><span class="hs-comment">--    e.g. T k (a::k)   Since k appear in a kind it'll</span><span>
</span><span id="line-1699"></span><span>                 </span><span class="hs-comment">--    be in dv_kvs, and is dependent. So remove it from</span><span>
</span><span id="line-1700"></span><span>                 </span><span class="hs-comment">--    dv_tvs which will also contain k</span><span>
</span><span id="line-1701"></span><span>                 </span><span class="hs-comment">-- NB kinds of tvs are zonked by zonkTyCoVarsAndFV</span><span>
</span><span id="line-1702"></span><span>
</span><span id="line-1703"></span><span>             </span><span class="hs-comment">-- In the non-PolyKinds case, default the kind variables</span><span>
</span><span id="line-1704"></span><span>             </span><span class="hs-comment">-- to *, and zonk the tyvars as usual.  Notice that this</span><span>
</span><span id="line-1705"></span><span>             </span><span class="hs-comment">-- may make quantifyTyVars return a shorter list</span><span>
</span><span id="line-1706"></span><span>             </span><span class="hs-comment">-- than it was passed, but that's ok</span><span>
</span><span id="line-1707"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077572"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077572"><span class="hs-identifier hs-var">poly_kinds</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#PolyKinds"><span class="hs-identifier hs-var">LangExt.PolyKinds</span></a></span><span>
</span><span id="line-1708"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077569"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077569"><span class="hs-identifier hs-var">dep_kvs'</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar))
-&gt; [TyVar] -&gt; TcM [TyVar]
forall (m :: * -&gt; *) a b.
Applicative m =&gt;
(a -&gt; m (Maybe b)) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#mapMaybeM"><span class="hs-identifier hs-var">mapMaybeM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
</span><a href="#local-6989586621681077567"><span class="hs-identifier hs-var">zonk_quant</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077572"><span class="hs-identifier hs-var">poly_kinds</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077577"><span class="hs-identifier hs-var">dep_kvs</span></a></span><span>
</span><span id="line-1709"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077566"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077566"><span class="hs-identifier hs-var">nondep_tvs'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar))
-&gt; [TyVar] -&gt; TcM [TyVar]
forall (m :: * -&gt; *) a b.
Applicative m =&gt;
(a -&gt; m (Maybe b)) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#mapMaybeM"><span class="hs-identifier hs-var">mapMaybeM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
</span><a href="#local-6989586621681077567"><span class="hs-identifier hs-var">zonk_quant</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>            </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077574"><span class="hs-identifier hs-var">nondep_tvs</span></a></span><span>
</span><span id="line-1710"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077565"><span class="annot"><span class="annottext">final_qtvs :: [TyVar]
</span><a href="#local-6989586621681077565"><span class="hs-identifier hs-var hs-var">final_qtvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077569"><span class="hs-identifier hs-var">dep_kvs'</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; [TyVar] -&gt; [TyVar]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077566"><span class="hs-identifier hs-var">nondep_tvs'</span></a></span><span>
</span><span id="line-1711"></span><span>           </span><span class="hs-comment">-- Because of the order, any kind variables</span><span>
</span><span id="line-1712"></span><span>           </span><span class="hs-comment">-- mentioned in the kinds of the nondep_tvs'</span><span>
</span><span id="line-1713"></span><span>           </span><span class="hs-comment">-- now refer to the dep_kvs'</span><span>
</span><span id="line-1714"></span><span>
</span><span id="line-1715"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;quantifyTyVars 2&quot;</span></span><span>
</span><span id="line-1716"></span><span>           </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;nondep:&quot;</span></span><span>     </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077574"><span class="hs-identifier hs-var">nondep_tvs</span></a></span><span>
</span><span id="line-1717"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dep:&quot;</span></span><span>        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077577"><span class="hs-identifier hs-var">dep_kvs</span></a></span><span>
</span><span id="line-1718"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dep_kvs'&quot;</span></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077569"><span class="hs-identifier hs-var">dep_kvs'</span></a></span><span>
</span><span id="line-1719"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;nondep_tvs'&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077566"><span class="hs-identifier hs-var">nondep_tvs'</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1720"></span><span>
</span><span id="line-1721"></span><span>       </span><span class="hs-comment">-- We should never quantify over coercion variables; check this</span><span>
</span><span id="line-1722"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077564"><span class="annot"><span class="annottext">co_vars :: [TyVar]
</span><a href="#local-6989586621681077564"><span class="hs-identifier hs-var hs-var">co_vars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; Bool) -&gt; [TyVar] -&gt; [TyVar]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isCoVar"><span class="hs-identifier hs-var">isCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077565"><span class="hs-identifier hs-var">final_qtvs</span></a></span><span>
</span><span id="line-1723"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-identifier">MASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">co_vars</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">co_vars</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1724"></span><span>
</span><span id="line-1725"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; TcM [TyVar]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077565"><span class="hs-identifier hs-var">final_qtvs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1726"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1727"></span><span>    </span><span class="hs-comment">-- zonk_quant returns a tyvar if it should be quantified over;</span><span>
</span><span id="line-1728"></span><span>    </span><span class="hs-comment">-- otherwise, it returns Nothing. The latter case happens for</span><span>
</span><span id="line-1729"></span><span>    </span><span class="hs-comment">--    * Kind variables, with -XNoPolyKinds: don't quantify over these</span><span>
</span><span id="line-1730"></span><span>    </span><span class="hs-comment">--    * RuntimeRep variables: we never quantify over these</span><span>
</span><span id="line-1731"></span><span>    </span><span id="local-6989586621681077567"><span class="annot"><span class="annottext">zonk_quant :: Bool -&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
</span><a href="#local-6989586621681077567"><span class="hs-identifier hs-var hs-var">zonk_quant</span></a></span></span><span> </span><span id="local-6989586621681077556"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077556"><span class="hs-identifier hs-var">default_kind</span></a></span></span><span> </span><span id="local-6989586621681077555"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077555"><span class="hs-identifier hs-var">tkv</span></a></span></span><span>
</span><span id="line-1732"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077555"><span class="hs-identifier hs-var">tkv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1733"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TyVar
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-comment">-- this can happen for a covar that's associated with</span><span>
</span><span id="line-1734"></span><span>                         </span><span class="hs-comment">-- a coercion hole. Test case: typecheck/should_compile/T2494</span><span>
</span><span id="line-1735"></span><span>
</span><span id="line-1736"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTcTyVar"><span class="hs-identifier hs-var">isTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077555"><span class="hs-identifier hs-var">tkv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1737"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Maybe TyVar
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077555"><span class="hs-identifier hs-var">tkv</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- For associated types in a class with a standalone</span><span>
</span><span id="line-1738"></span><span>                           </span><span class="hs-comment">-- kind signature, we have the class variables in</span><span>
</span><span id="line-1739"></span><span>                           </span><span class="hs-comment">-- scope, and they are TyVars not TcTyVars</span><span>
</span><span id="line-1740"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1741"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077553"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077553"><span class="hs-identifier hs-var">deflt_done</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#defaultTyVar"><span class="hs-identifier hs-var">defaultTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077556"><span class="hs-identifier hs-var">default_kind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077555"><span class="hs-identifier hs-var">tkv</span></a></span><span>
</span><span id="line-1742"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077553"><span class="hs-identifier hs-var">deflt_done</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1743"></span><span>               </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TyVar
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-1744"></span><span>               </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077552"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077552"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#skolemiseQuantifiedTyVar"><span class="hs-identifier hs-var">skolemiseQuantifiedTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077555"><span class="hs-identifier hs-var">tkv</span></a></span><span>
</span><span id="line-1745"></span><span>                           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Maybe TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe TyVar)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Maybe TyVar
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077552"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1746"></span><span>
</span><span id="line-1747"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#isQuantifiableTv"><span class="hs-identifier hs-type">isQuantifiableTv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span>   </span><span class="hs-comment">-- Level of the context, outside the quantification</span><span>
</span><span id="line-1748"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-1749"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1750"></span><span id="isQuantifiableTv"><span class="annot"><span class="annottext">isQuantifiableTv :: TcLevel -&gt; TyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcMType.html#isQuantifiableTv"><span class="hs-identifier hs-var hs-var">isQuantifiableTv</span></a></span></span><span> </span><span id="local-6989586621681077551"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077551"><span class="hs-identifier hs-var">outer_tclvl</span></a></span></span><span> </span><span id="local-6989586621681077550"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077550"><span class="hs-identifier hs-var">tcv</span></a></span></span><span>
</span><span id="line-1751"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTcTyVar"><span class="hs-identifier hs-var">isTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077550"><span class="hs-identifier hs-var">tcv</span></a></span><span>  </span><span class="hs-comment">-- Might be a CoVar; change this when gather covars separately</span><span>
</span><span id="line-1752"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#tcTyVarLevel"><span class="hs-identifier hs-var">tcTyVarLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077550"><span class="hs-identifier hs-var">tcv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681077551"><span class="hs-identifier hs-var">outer_tclvl</span></a></span><span>
</span><span id="line-1753"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1754"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1755"></span><span>
</span><span id="line-1756"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkAndSkolemise"><span class="hs-identifier hs-type">zonkAndSkolemise</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVar"><span class="hs-identifier hs-type">TcTyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCoVar"><span class="hs-identifier hs-type">TcTyCoVar</span></a></span><span>
</span><span id="line-1757"></span><span class="hs-comment">-- A tyvar binder is never a unification variable (TauTv),</span><span>
</span><span id="line-1758"></span><span class="hs-comment">-- rather it is always a skolem. It *might* be a TyVarTv.</span><span>
</span><span id="line-1759"></span><span class="hs-comment">-- (Because non-CUSK type declarations use TyVarTvs.)</span><span>
</span><span id="line-1760"></span><span class="hs-comment">-- Regardless, it may have a kind that has not yet been zonked,</span><span>
</span><span id="line-1761"></span><span class="hs-comment">-- and may include kind unification variables.</span><span>
</span><span id="line-1762"></span><span id="zonkAndSkolemise"><span class="annot"><span class="annottext">zonkAndSkolemise :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkAndSkolemise"><span class="hs-identifier hs-var hs-var">zonkAndSkolemise</span></a></span></span><span> </span><span id="local-6989586621681077547"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077547"><span class="hs-identifier hs-var">tyvar</span></a></span></span><span>
</span><span id="line-1763"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTyVarTyVar"><span class="hs-identifier hs-var">isTyVarTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077547"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1764"></span><span>     </span><span class="hs-comment">-- We want to preserve the binding location of the original TyVarTv.</span><span>
</span><span id="line-1765"></span><span>     </span><span class="hs-comment">-- This is important for error messages. If we don't do this, then</span><span>
</span><span id="line-1766"></span><span>     </span><span class="hs-comment">-- we get bad locations in, e.g., typecheck/should_fail/T2688</span><span>
</span><span id="line-1767"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077545"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077545"><span class="hs-identifier hs-var">zonked_tyvar</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-var">zonkTcTyVarToTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077547"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1768"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#skolemiseQuantifiedTyVar"><span class="hs-identifier hs-var">skolemiseQuantifiedTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077545"><span class="hs-identifier hs-var">zonked_tyvar</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1769"></span><span>
</span><span id="line-1770"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1771"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isImmutableTyVar</span><span> </span><span class="hs-identifier">tyvar</span><span> </span><span class="hs-operator">||</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">tyvar</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">pprTyVar</span><span> </span><span class="hs-identifier">tyvar</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1772"></span><span>    </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077547"><span class="hs-identifier hs-var">tyvar</span></a></span><span>
</span><span id="line-1773"></span><span>
</span><span id="line-1774"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#skolemiseQuantifiedTyVar"><span class="hs-identifier hs-type">skolemiseQuantifiedTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-1775"></span><span class="hs-comment">-- The quantified type variables often include meta type variables</span><span>
</span><span id="line-1776"></span><span class="hs-comment">-- we want to freeze them into ordinary type variables</span><span>
</span><span id="line-1777"></span><span class="hs-comment">-- The meta tyvar is updated to point to the new skolem TyVar.  Now any</span><span>
</span><span id="line-1778"></span><span class="hs-comment">-- bound occurrences of the original type variable will get zonked to</span><span>
</span><span id="line-1779"></span><span class="hs-comment">-- the immutable version.</span><span>
</span><span id="line-1780"></span><span class="hs-comment">--</span><span>
</span><span id="line-1781"></span><span class="hs-comment">-- We leave skolem TyVars alone; they are immutable.</span><span>
</span><span id="line-1782"></span><span class="hs-comment">--</span><span>
</span><span id="line-1783"></span><span class="hs-comment">-- This function is called on both kind and type variables,</span><span>
</span><span id="line-1784"></span><span class="hs-comment">-- but kind variables *only* if PolyKinds is on.</span><span>
</span><span id="line-1785"></span><span>
</span><span id="line-1786"></span><span id="skolemiseQuantifiedTyVar"><span class="annot"><span class="annottext">skolemiseQuantifiedTyVar :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#skolemiseQuantifiedTyVar"><span class="hs-identifier hs-var hs-var">skolemiseQuantifiedTyVar</span></a></span></span><span> </span><span id="local-6989586621681077542"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077542"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1787"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077542"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1788"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-type">SkolemTv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077541"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077541"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077542"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1789"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-identifier hs-var">setTyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077542"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077541"><span class="hs-identifier hs-var">kind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1790"></span><span>        </span><span class="hs-comment">-- It might be a skolem type variable,</span><span>
</span><span id="line-1791"></span><span>        </span><span class="hs-comment">-- for example from a user type signature</span><span>
</span><span id="line-1792"></span><span>
</span><span id="line-1793"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#skolemiseUnboundMetaTyVar"><span class="hs-identifier hs-var">skolemiseUnboundMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077542"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1794"></span><span>
</span><span id="line-1795"></span><span>      </span><span id="local-6989586621681077540"><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077540"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;skolemiseQuantifiedTyVar&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077542"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- RuntimeUnk</span><span>
</span><span id="line-1796"></span><span>
</span><span id="line-1797"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#defaultTyVar"><span class="hs-identifier hs-type">defaultTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>      </span><span class="hs-comment">-- True &lt;=&gt; please default this kind variable to *</span><span>
</span><span id="line-1798"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>   </span><span class="hs-comment">-- If it's a MetaTyVar then it is unbound</span><span>
</span><span id="line-1799"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- True &lt;=&gt; defaulted away altogether</span><span>
</span><span id="line-1800"></span><span>
</span><span id="line-1801"></span><span id="defaultTyVar"><span class="annot"><span class="annottext">defaultTyVar :: Bool -&gt; TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="GHC.Tc.Utils.TcMType.html#defaultTyVar"><span class="hs-identifier hs-var hs-var">defaultTyVar</span></a></span></span><span> </span><span id="local-6989586621681077539"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077539"><span class="hs-identifier hs-var">default_kind</span></a></span></span><span> </span><span id="local-6989586621681077538"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1802"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isMetaTyVar"><span class="hs-identifier hs-var">isMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1803"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1804"></span><span>
</span><span id="line-1805"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isTyVarTyVar"><span class="hs-identifier hs-var">isTyVarTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1806"></span><span>    </span><span class="hs-comment">-- Do not default TyVarTvs. Doing so would violate the invariants</span><span>
</span><span id="line-1807"></span><span>    </span><span class="hs-comment">-- on TyVarTvs; see Note [Signature skolems] in GHC.Tc.Utils.TcType.</span><span>
</span><span id="line-1808"></span><span>    </span><span class="hs-comment">-- #13343 is an example; #14555 is another</span><span>
</span><span id="line-1809"></span><span>    </span><span class="hs-comment">-- See Note [Inferring kinds for type declarations] in GHC.Tc.TyCl</span><span>
</span><span id="line-1810"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1811"></span><span>
</span><span id="line-1812"></span><span>
</span><span id="line-1813"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Core.Type.html#isRuntimeRepVar"><span class="hs-identifier hs-var">isRuntimeRepVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span>  </span><span class="hs-comment">-- Do not quantify over a RuntimeRep var</span><span>
</span><span id="line-1814"></span><span>                        </span><span class="hs-comment">-- unless it is a TyVarTv, handled earlier</span><span>
</span><span id="line-1815"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Defaulting a RuntimeRep var to LiftedRep&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1816"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var">writeMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#liftedRepTy"><span class="hs-identifier hs-var">liftedRepTy</span></a></span><span>
</span><span id="line-1817"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1818"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Core.Type.html#isMultiplicityVar"><span class="hs-identifier hs-var">isMultiplicityVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1819"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Defaulting a Multiplicty var to Many&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1820"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var">writeMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#manyDataConTy"><span class="hs-identifier hs-var">manyDataConTy</span></a></span><span>
</span><span id="line-1821"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1822"></span><span>
</span><span id="line-1823"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681077539"><span class="hs-identifier hs-var">default_kind</span></a></span><span>            </span><span class="hs-comment">-- -XNoPolyKinds and this is a kind var</span><span>
</span><span id="line-1824"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="#local-6989586621681077533"><span class="hs-identifier hs-var">default_kind_var</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077538"><span class="hs-identifier hs-var">tv</span></a></span><span>     </span><span class="hs-comment">-- so default it to * if possible</span><span>
</span><span id="line-1825"></span><span>
</span><span id="line-1826"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1827"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1828"></span><span>
</span><span id="line-1829"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1830"></span><span>    </span><span class="annot"><a href="#local-6989586621681077533"><span class="hs-identifier hs-type">default_kind_var</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1831"></span><span>       </span><span class="hs-comment">-- defaultKindVar is used exclusively with -XNoPolyKinds</span><span>
</span><span id="line-1832"></span><span>       </span><span class="hs-comment">-- See Note [Defaulting with -XNoPolyKinds]</span><span>
</span><span id="line-1833"></span><span>       </span><span class="hs-comment">-- It takes an (unconstrained) meta tyvar and defaults it.</span><span>
</span><span id="line-1834"></span><span>       </span><span class="hs-comment">-- Works only on vars of type *; for other kinds, it issues an error.</span><span>
</span><span id="line-1835"></span><span>    </span><span id="local-6989586621681077533"><span class="annot"><span class="annottext">default_kind_var :: TyVar -&gt; TcRnIf TcGblEnv TcLclEnv Bool
</span><a href="#local-6989586621681077533"><span class="hs-identifier hs-var hs-var">default_kind_var</span></a></span></span><span> </span><span id="local-6989586621681077532"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077532"><span class="hs-identifier hs-var">kv</span></a></span></span><span>
</span><span id="line-1836"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Bool
</span><a href="GHC.Core.Type.html#isLiftedTypeKind"><span class="hs-identifier hs-var">isLiftedTypeKind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077532"><span class="hs-identifier hs-var">kv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1837"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Defaulting a kind var to *&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077532"><span class="hs-identifier hs-var">kv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1838"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var">writeMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077532"><span class="hs-identifier hs-var">kv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span>
</span><span id="line-1839"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1840"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1841"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot default kind variable&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077528"><span class="hs-identifier hs-var">kv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1842"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;of kind:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077528"><span class="hs-identifier hs-var">kv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1843"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Perhaps enable PolyKinds or add a kind signature&quot;</span></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1844"></span><span>           </span><span class="hs-comment">-- We failed to default it, so return False to say so.</span><span>
</span><span id="line-1845"></span><span>           </span><span class="hs-comment">-- Hence, it'll get skolemised.  That might seem odd, but we must either</span><span>
</span><span id="line-1846"></span><span>           </span><span class="hs-comment">-- promote, skolemise, or zap-to-Any, to satisfy GHC.Tc.Gen.HsType</span><span>
</span><span id="line-1847"></span><span>           </span><span class="hs-comment">--    Note [Recipe for checking a signature]</span><span>
</span><span id="line-1848"></span><span>           </span><span class="hs-comment">-- Otherwise we get level-number assertion failures. It doesn't matter much</span><span>
</span><span id="line-1849"></span><span>           </span><span class="hs-comment">-- because we are in an error situation anyway.</span><span>
</span><span id="line-1850"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRnIf TcGblEnv TcLclEnv Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1851"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-1852"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1853"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077528"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077528"><span class="hs-identifier hs-var">kv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TyVar -&gt; (TidyEnv, TyVar)
</span><a href="GHC.Core.TyCo.Tidy.html#tidyOpenTyCoVar"><span class="hs-identifier hs-var">tidyOpenTyCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="GHC.Types.Var.Env.html#emptyTidyEnv"><span class="hs-identifier hs-var">emptyTidyEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077532"><span class="hs-identifier hs-var">kv</span></a></span><span>
</span><span id="line-1854"></span><span>
</span><span id="line-1855"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#skolemiseUnboundMetaTyVar"><span class="hs-identifier hs-type">skolemiseUnboundMetaTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span>
</span><span id="line-1856"></span><span class="hs-comment">-- We have a Meta tyvar with a ref-cell inside it</span><span>
</span><span id="line-1857"></span><span class="hs-comment">-- Skolemise it, so that we are totally out of Meta-tyvar-land</span><span>
</span><span id="line-1858"></span><span class="hs-comment">-- We create a skolem TcTyVar, not a regular TyVar</span><span>
</span><span id="line-1859"></span><span class="hs-comment">--   See Note [Zonking to Skolem]</span><span>
</span><span id="line-1860"></span><span id="skolemiseUnboundMetaTyVar"><span class="annot"><span class="annottext">skolemiseUnboundMetaTyVar :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#skolemiseUnboundMetaTyVar"><span class="hs-identifier hs-var hs-var">skolemiseUnboundMetaTyVar</span></a></span></span><span> </span><span id="local-6989586621681077525"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-1861"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isMetaTyVar</span><span> </span><span class="hs-identifier">tv</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1862"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRn () -&gt; TcRn ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; TcRn ()
</span><a href="#local-6989586621681077523"><span class="hs-identifier hs-var">check_empty</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1863"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077522"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681077522"><span class="hs-identifier hs-var">here</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn SrcSpan
</span><a href="GHC.Tc.Utils.Monad.html#getSrcSpanM"><span class="hs-identifier hs-var">getSrcSpanM</span></a></span><span>    </span><span class="hs-comment">-- Get the location from &quot;here&quot;</span><span>
</span><span id="line-1864"></span><span>                                 </span><span class="hs-comment">-- ie where we are generalising</span><span>
</span><span id="line-1865"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077520"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077520"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1866"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077519"><span class="annot"><span class="annottext">tv_name :: Name
</span><a href="#local-6989586621681077519"><span class="hs-identifier hs-var hs-var">tv_name</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1867"></span><span>              </span><span class="hs-comment">-- See Note [Skolemising and identity]</span><span>
</span><span id="line-1868"></span><span>              </span><span id="local-6989586621681077518"><span class="annot"><span class="annottext">final_name :: Name
</span><a href="#local-6989586621681077518"><span class="hs-identifier hs-var hs-var">final_name</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isSystemName"><span class="hs-identifier hs-var">isSystemName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077519"><span class="hs-identifier hs-var">tv_name</span></a></span><span>
</span><span id="line-1869"></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Unique
</span><a href="GHC.Types.Name.html#nameUnique"><span class="hs-identifier hs-var">nameUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077519"><span class="hs-identifier hs-var">tv_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1870"></span><span>                                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077519"><span class="hs-identifier hs-var">tv_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681077522"><span class="hs-identifier hs-var">here</span></a></span><span>
</span><span id="line-1871"></span><span>                         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1872"></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077519"><span class="hs-identifier hs-var">tv_name</span></a></span><span>
</span><span id="line-1873"></span><span>              </span><span id="local-6989586621681077514"><span class="annot"><span class="annottext">final_tv :: TyVar
</span><a href="#local-6989586621681077514"><span class="hs-identifier hs-var hs-var">final_tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Kind -&gt; TcTyVarDetails -&gt; TyVar
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681077518"><span class="hs-identifier hs-var">final_name</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077520"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681077513"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-1874"></span><span>
</span><span id="line-1875"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Skolemising&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;:=&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077514"><span class="hs-identifier hs-var">final_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1876"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#writeMetaTyVar"><span class="hs-identifier hs-var">writeMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077514"><span class="hs-identifier hs-var">final_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1877"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077514"><span class="hs-identifier hs-var">final_tv</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1878"></span><span>
</span><span id="line-1879"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1880"></span><span>    </span><span id="local-6989586621681077513"><span class="annot"><span class="annottext">details :: TcTyVarDetails
</span><a href="#local-6989586621681077513"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Bool -&gt; TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-var">SkolemTv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#metaTyVarTcLevel"><span class="hs-identifier hs-var">metaTyVarTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077525"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1881"></span><span>    </span><span id="local-6989586621681077523"><span class="annot"><span class="annottext">check_empty :: TyVar -&gt; TcRn ()
</span><a href="#local-6989586621681077523"><span class="hs-identifier hs-var hs-var">check_empty</span></a></span></span><span> </span><span id="local-6989586621681077503"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077503"><span class="hs-identifier hs-var">tv</span></a></span></span><span>       </span><span class="hs-comment">-- [Sept 04] Check for non-empty.</span><span>
</span><span id="line-1882"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRn () -&gt; TcRn ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Utils.Misc.html#debugIsOn"><span class="hs-identifier hs-var">debugIsOn</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>  </span><span class="hs-comment">-- See note [Silly Type Synonym]</span><span>
</span><span id="line-1883"></span><span>        </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077502"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077502"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM MetaDetails
</span><a href="GHC.Tc.Utils.TcMType.html#readMetaTyVar"><span class="hs-identifier hs-var">readMetaTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077503"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1884"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077502"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1885"></span><span>               </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-1886"></span><span>               </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681077501"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077501"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">ty</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1887"></span><span>                              </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1888"></span><span>
</span><span id="line-1889"></span><span class="hs-comment">{- Note [Defaulting with -XNoPolyKinds]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider

  data Compose f g a = Mk (f (g a))

We infer

  Compose :: forall k1 k2. (k2 -&gt; *) -&gt; (k1 -&gt; k2) -&gt; k1 -&gt; *
  Mk :: forall k1 k2 (f :: k2 -&gt; *) (g :: k1 -&gt; k2) (a :: k1).
        f (g a) -&gt; Compose k1 k2 f g a

Now, in another module, we have -XNoPolyKinds -XDataKinds in effect.
What does 'Mk mean? Pre GHC-8.0 with -XNoPolyKinds,
we just defaulted all kind variables to *. But that's no good here,
because the kind variables in 'Mk aren't of kind *, so defaulting to *
is ill-kinded.

After some debate on #11334, we decided to issue an error in this case.
The code is in defaultKindVar.

Note [What is a meta variable?]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A &quot;meta type-variable&quot;, also know as a &quot;unification variable&quot; is a placeholder
introduced by the typechecker for an as-yet-unknown monotype.

For example, when we see a call `reverse (f xs)`, we know that we calling
    reverse :: forall a. [a] -&gt; [a]
So we know that the argument `f xs` must be a &quot;list of something&quot;. But what is
the &quot;something&quot;? We don't know until we explore the `f xs` a bit more. So we set
out what we do know at the call of `reverse` by instantiating its type with a fresh
meta tyvar, `alpha` say. So now the type of the argument `f xs`, and of the
result, is `[alpha]`. The unification variable `alpha` stands for the
as-yet-unknown type of the elements of the list.

As type inference progresses we may learn more about `alpha`. For example, suppose
`f` has the type
    f :: forall b. b -&gt; [Maybe b]
Then we instantiate `f`'s type with another fresh unification variable, say
`beta`; and equate `f`'s result type with reverse's argument type, thus
`[alpha] ~ [Maybe beta]`.

Now we can solve this equality to learn that `alpha ~ Maybe beta`, so we've
refined our knowledge about `alpha`. And so on.

If you found this Note useful, you may also want to have a look at
Section 5 of &quot;Practical type inference for higher rank types&quot; (Peyton Jones,
Vytiniotis, Weirich and Shields. J. Functional Programming. 2011).

Note [What is zonking?]
~~~~~~~~~~~~~~~~~~~~~~~
GHC relies heavily on mutability in the typechecker for efficient operation.
For this reason, throughout much of the type checking process meta type
variables (the MetaTv constructor of TcTyVarDetails) are represented by mutable
variables (known as TcRefs).

Zonking is the process of ripping out these mutable variables and replacing them
with a real Type. This involves traversing the entire type expression, but the
interesting part of replacing the mutable variables occurs in zonkTyVarOcc.

There are two ways to zonk a Type:

 * zonkTcTypeToType, which is intended to be used at the end of type-checking
   for the final zonk. It has to deal with unfilled metavars, either by filling
   it with a value like Any or failing (determined by the UnboundTyVarZonker
   used).

 * zonkTcType, which will happily ignore unfilled metavars. This is the
   appropriate function to use while in the middle of type-checking.

Note [Zonking to Skolem]
~~~~~~~~~~~~~~~~~~~~~~~~
We used to zonk quantified type variables to regular TyVars.  However, this
leads to problems.  Consider this program from the regression test suite:

  eval :: Int -&gt; String -&gt; String -&gt; String
  eval 0 root actual = evalRHS 0 root actual

  evalRHS :: Int -&gt; a
  evalRHS 0 root actual = eval 0 root actual

It leads to the deferral of an equality (wrapped in an implication constraint)

  forall a. () =&gt; ((String -&gt; String -&gt; String) ~ a)

which is propagated up to the toplevel (see GHC.Tc.Solver.tcSimplifyInferCheck).
In the meantime `a' is zonked and quantified to form `evalRHS's signature.
This has the *side effect* of also zonking the `a' in the deferred equality
(which at this point is being handed around wrapped in an implication
constraint).

Finally, the equality (with the zonked `a') will be handed back to the
simplifier by GHC.Tc.Module.tcRnSrcDecls calling GHC.Tc.Solver.tcSimplifyTop.
If we zonk `a' with a regular type variable, we will have this regular type
variable now floating around in the simplifier, which in many places assumes to
only see proper TcTyVars.

We can avoid this problem by zonking with a skolem TcTyVar.  The
skolem is rigid (which we require for a quantified variable), but is
still a TcTyVar that the simplifier knows how to deal with.

Note [Skolemising and identity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In some places, we make a TyVarTv for a binder. E.g.
    class C a where ...
As Note [Inferring kinds for type declarations] discusses,
we make a TyVarTv for 'a'.  Later we skolemise it, and we'd
like to retain its identity, location info etc.  (If we don't
retain its identity we'll have to do some pointless swizzling;
see GHC.Tc.TyCl.swizzleTcTyConBndrs.  If we retain its identity
but not its location we'll lose the detailed binding site info.

Conclusion: use the Name of the TyVarTv.  But we don't want
to do that when skolemising random unification variables;
there the location we want is the skolemisation site.

Fortunately we can tell the difference: random unification
variables have System Names.  That's why final_name is
set based on the isSystemName test.


Note [Silly Type Synonyms]
~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:
        type C u a = u  -- Note 'a' unused

        foo :: (forall a. C u a -&gt; C u a) -&gt; u
        foo x = ...

        bar :: Num u =&gt; u
        bar = foo (\t -&gt; t + t)

* From the (\t -&gt; t+t) we get type  {Num d} =&gt;  d -&gt; d
  where d is fresh.

* Now unify with type of foo's arg, and we get:
        {Num (C d a)} =&gt;  C d a -&gt; C d a
  where a is fresh.

* Now abstract over the 'a', but float out the Num (C d a) constraint
  because it does not 'really' mention a.  (see exactTyVarsOfType)
  The arg to foo becomes
        \/\a -&gt; \t -&gt; t+t

* So we get a dict binding for Num (C d a), which is zonked to give
        a = ()
  [Note Sept 04: now that we are zonking quantified type variables
  on construction, the 'a' will be frozen as a regular tyvar on
  quantification, so the floated dict will still have type (C d a).
  Which renders this whole note moot; happily!]

* Then the \/\a abstraction has a zonked 'a' in it.

All very silly.   I think its harmless to ignore the problem.  We'll end up with
a \/\a in the final result but all the occurrences of a will be zonked to ()

************************************************************************
*                                                                      *
              Zonking types
*                                                                      *
************************************************************************

-}</span><span>
</span><span id="line-2052"></span><span>
</span><span id="line-2053"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypeAndFV"><span class="hs-identifier hs-type">zonkTcTypeAndFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DTyCoVarSet"><span class="hs-identifier hs-type">DTyCoVarSet</span></a></span><span>
</span><span id="line-2054"></span><span class="hs-comment">-- Zonk a type and take its free variables</span><span>
</span><span id="line-2055"></span><span class="hs-comment">-- With kind polymorphism it can be essential to zonk *first*</span><span>
</span><span id="line-2056"></span><span class="hs-comment">-- so that we find the right set of free variables.  Eg</span><span>
</span><span id="line-2057"></span><span class="hs-comment">--    forall k1. forall (a:k2). a</span><span>
</span><span id="line-2058"></span><span class="hs-comment">-- where k2:=k1 is in the substitution.  We don't want</span><span>
</span><span id="line-2059"></span><span class="hs-comment">-- k2 to look free in this type!</span><span>
</span><span id="line-2060"></span><span id="zonkTcTypeAndFV"><span class="annot"><span class="annottext">zonkTcTypeAndFV :: Kind -&gt; TcM DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypeAndFV"><span class="hs-identifier hs-var hs-var">zonkTcTypeAndFV</span></a></span></span><span> </span><span id="local-6989586621681077498"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077498"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-2061"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; DTyVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypeDSet"><span class="hs-identifier hs-var">tyCoVarsOfTypeDSet</span></a></span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; DTyVarSet) -&gt; TcM Kind -&gt; TcM DTyVarSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077498"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2062"></span><span>
</span><span id="line-2063"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVar"><span class="hs-identifier hs-type">zonkTyCoVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-2064"></span><span class="hs-comment">-- Works on TyVars and TcTyVars</span><span>
</span><span id="line-2065"></span><span id="zonkTyCoVar"><span class="annot"><span class="annottext">zonkTyCoVar :: TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVar"><span class="hs-identifier hs-var hs-var">zonkTyCoVar</span></a></span></span><span> </span><span id="local-6989586621681077494"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077494"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTcTyVar"><span class="hs-identifier hs-var">isTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077494"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-var">zonkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077494"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2066"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span>   </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077494"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar -&gt; TcM Kind
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077494"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2067"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT2</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">isCoVar</span><span> </span><span class="hs-identifier">tv</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">tv</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-2068"></span><span>                                </span><span class="annot"><span class="annottext">Coercion -&gt; Kind
</span><a href="GHC.Core.Type.html#mkCoercionTy"><span class="hs-identifier hs-var">mkCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; Kind) -&gt; (TyVar -&gt; Coercion) -&gt; TyVar -&gt; Kind
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar -&gt; TcM Kind
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077494"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2069"></span><span>   </span><span class="hs-comment">-- Hackily, when typechecking type and class decls</span><span>
</span><span id="line-2070"></span><span>   </span><span class="hs-comment">-- we have TyVars in scope added (only) in</span><span>
</span><span id="line-2071"></span><span>   </span><span class="hs-comment">-- GHC.Tc.Gen.HsType.bindTyClTyVars, but it seems</span><span>
</span><span id="line-2072"></span><span>   </span><span class="hs-comment">-- painful to make them into TcTyVars there</span><span>
</span><span id="line-2073"></span><span>
</span><span id="line-2074"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFV"><span class="hs-identifier hs-type">zonkTyCoVarsAndFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span>
</span><span id="line-2075"></span><span id="zonkTyCoVarsAndFV"><span class="annot"><span class="annottext">zonkTyCoVarsAndFV :: TcTyVarSet -&gt; TcM TcTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFV"><span class="hs-identifier hs-var hs-var">zonkTyCoVarsAndFV</span></a></span></span><span> </span><span id="local-6989586621681077489"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077489"><span class="hs-identifier hs-var">tycovars</span></a></span></span><span>
</span><span id="line-2076"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Kind] -&gt; TcTyVarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypes"><span class="hs-identifier hs-var">tyCoVarsOfTypes</span></a></span><span> </span><span class="annot"><span class="annottext">([Kind] -&gt; TcTyVarSet) -&gt; TcM [Kind] -&gt; TcM TcTyVarSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcM Kind) -&gt; [TyVar] -&gt; TcM [Kind]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVar"><span class="hs-identifier hs-var">zonkTyCoVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcTyVarSet -&gt; [TyVar]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077489"><span class="hs-identifier hs-var">tycovars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2077"></span><span>  </span><span class="hs-comment">-- It's OK to use nonDetEltsUniqSet here because we immediately forget about</span><span>
</span><span id="line-2078"></span><span>  </span><span class="hs-comment">-- the ordering by turning it into a nondeterministic set and the order</span><span>
</span><span id="line-2079"></span><span>  </span><span class="hs-comment">-- of zonking doesn't matter for determinism.</span><span>
</span><span id="line-2080"></span><span>
</span><span id="line-2081"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkDTyCoVarSetAndFV"><span class="hs-identifier hs-type">zonkDTyCoVarSetAndFV</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DTyCoVarSet"><span class="hs-identifier hs-type">DTyCoVarSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#DTyCoVarSet"><span class="hs-identifier hs-type">DTyCoVarSet</span></a></span><span>
</span><span id="line-2082"></span><span id="zonkDTyCoVarSetAndFV"><span class="annot"><span class="annottext">zonkDTyCoVarSetAndFV :: DTyVarSet -&gt; TcM DTyVarSet
</span><a href="GHC.Tc.Utils.TcMType.html#zonkDTyCoVarSetAndFV"><span class="hs-identifier hs-var hs-var">zonkDTyCoVarSetAndFV</span></a></span></span><span> </span><span id="local-6989586621681077487"><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077487"><span class="hs-identifier hs-var">tycovars</span></a></span></span><span>
</span><span id="line-2083"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; DTyVarSet
</span><a href="GHC.Types.Var.Set.html#mkDVarSet"><span class="hs-identifier hs-var">mkDVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">([TyVar] -&gt; DTyVarSet) -&gt; TcM [TyVar] -&gt; TcM DTyVarSet
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyVar] -&gt; TcM [TyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFVList"><span class="hs-identifier hs-var">zonkTyCoVarsAndFVList</span></a></span><span> </span><span class="annot"><span class="annottext">([TyVar] -&gt; TcM [TyVar]) -&gt; [TyVar] -&gt; TcM [TyVar]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet -&gt; [TyVar]
</span><a href="GHC.Types.Var.Set.html#dVarSetElems"><span class="hs-identifier hs-var">dVarSetElems</span></a></span><span> </span><span class="annot"><span class="annottext">DTyVarSet
</span><a href="#local-6989586621681077487"><span class="hs-identifier hs-var">tycovars</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2084"></span><span>
</span><span id="line-2085"></span><span class="hs-comment">-- Takes a list of TyCoVars, zonks them and returns a</span><span>
</span><span id="line-2086"></span><span class="hs-comment">-- deterministically ordered list of their free variables.</span><span>
</span><span id="line-2087"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFVList"><span class="hs-identifier hs-type">zonkTyCoVarsAndFVList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2088"></span><span id="zonkTyCoVarsAndFVList"><span class="annot"><span class="annottext">zonkTyCoVarsAndFVList :: [TyVar] -&gt; TcM [TyVar]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarsAndFVList"><span class="hs-identifier hs-var hs-var">zonkTyCoVarsAndFVList</span></a></span></span><span> </span><span id="local-6989586621681077485"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077485"><span class="hs-identifier hs-var">tycovars</span></a></span></span><span>
</span><span id="line-2089"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Kind] -&gt; [TyVar]
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypesList"><span class="hs-identifier hs-var">tyCoVarsOfTypesList</span></a></span><span> </span><span class="annot"><span class="annottext">([Kind] -&gt; [TyVar]) -&gt; TcM [Kind] -&gt; TcM [TyVar]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcM Kind) -&gt; [TyVar] -&gt; TcM [Kind]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVar"><span class="hs-identifier hs-var">zonkTyCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077485"><span class="hs-identifier hs-var">tycovars</span></a></span><span>
</span><span id="line-2090"></span><span>
</span><span id="line-2091"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVars"><span class="hs-identifier hs-type">zonkTcTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2092"></span><span id="zonkTcTyVars"><span class="annot"><span class="annottext">zonkTcTyVars :: [TyVar] -&gt; TcM [Kind]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVars"><span class="hs-identifier hs-var hs-var">zonkTcTyVars</span></a></span></span><span> </span><span id="local-6989586621681077483"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077483"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcM Kind) -&gt; [TyVar] -&gt; TcM [Kind]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-var">zonkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077483"><span class="hs-identifier hs-var">tyvars</span></a></span><span>
</span><span id="line-2093"></span><span>
</span><span id="line-2094"></span><span class="hs-comment">-----------------  Types</span><span>
</span><span id="line-2095"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-type">zonkTyCoVarKind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span>
</span><span id="line-2096"></span><span id="zonkTyCoVarKind"><span class="annot"><span class="annottext">zonkTyCoVarKind :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var hs-var">zonkTyCoVarKind</span></a></span></span><span> </span><span id="local-6989586621681077482"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077482"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077481"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077481"><span class="hs-identifier hs-var">kind'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077482"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2097"></span><span>                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-identifier hs-var">setTyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077482"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077481"><span class="hs-identifier hs-var">kind'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2098"></span><span>
</span><span id="line-2099"></span><span id="local-6989586621681078928"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKindBinder"><span class="hs-identifier hs-type">zonkTyCoVarKindBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#VarBndr"><span class="hs-identifier hs-type">VarBndr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681078928"><span class="hs-identifier hs-type">fl</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#VarBndr"><span class="hs-identifier hs-type">VarBndr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681078928"><span class="hs-identifier hs-type">fl</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-2100"></span><span id="zonkTyCoVarKindBinder"><span class="annot"><span class="annottext">zonkTyCoVarKindBinder :: forall fl. VarBndr TyVar fl -&gt; TcM (VarBndr TyVar fl)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKindBinder"><span class="hs-identifier hs-var hs-var">zonkTyCoVarKindBinder</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681077478"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077478"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681077477"><span class="annot"><span class="annottext">fl
</span><a href="#local-6989586621681077477"><span class="hs-identifier hs-var">fl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077476"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077476"><span class="hs-identifier hs-var">kind'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077478"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2101"></span><span>                                        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">VarBndr TyVar fl -&gt; TcM (VarBndr TyVar fl)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(VarBndr TyVar fl -&gt; TcM (VarBndr TyVar fl))
-&gt; VarBndr TyVar fl -&gt; TcM (VarBndr TyVar fl)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; fl -&gt; VarBndr TyVar fl
forall var argf. var -&gt; argf -&gt; VarBndr var argf
</span><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-var">Bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Var.html#setTyVarKind"><span class="hs-identifier hs-var">setTyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077478"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077476"><span class="hs-identifier hs-var">kind'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">fl
</span><a href="#local-6989586621681077477"><span class="hs-identifier hs-var">fl</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2102"></span><span>
</span><span id="line-2103"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
              Zonking constraints
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-2110"></span><span>
</span><span id="line-2111"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkImplication"><span class="hs-identifier hs-type">zonkImplication</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span>
</span><span id="line-2112"></span><span id="zonkImplication"><span class="annot"><span class="annottext">zonkImplication :: Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
</span><a href="GHC.Tc.Utils.TcMType.html#zonkImplication"><span class="hs-identifier hs-var hs-var">zonkImplication</span></a></span></span><span> </span><span id="local-6989586621681077475"><span class="annot"><span class="annottext">implic :: Implication
</span><a href="#local-6989586621681077475"><span class="hs-identifier hs-var">implic</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implic"><span class="hs-identifier hs-type">Implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_skols :: Implication -&gt; [TyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077473"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077473"><span class="hs-identifier hs-var">skols</span></a></span></span><span>
</span><span id="line-2113"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: Implication -&gt; [TyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077471"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077471"><span class="hs-identifier hs-var">given</span></a></span></span><span>
</span><span id="line-2114"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077470"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681077470"><span class="hs-identifier hs-var">wanted</span></a></span></span><span>
</span><span id="line-2115"></span><span>                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: Implication -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077468"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077468"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2116"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077467"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077467"><span class="hs-identifier hs-var">skols'</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar)
-&gt; [TyVar] -&gt; TcM [TyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077473"><span class="hs-identifier hs-var">skols</span></a></span><span>  </span><span class="hs-comment">-- Need to zonk their kinds!</span><span>
</span><span id="line-2117"></span><span>                                                </span><span class="hs-comment">-- as #7230 showed</span><span>
</span><span id="line-2118"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077466"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077466"><span class="hs-identifier hs-var">given'</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar)
-&gt; [TyVar] -&gt; TcM [TyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkEvVar"><span class="hs-identifier hs-var">zonkEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077471"><span class="hs-identifier hs-var">given</span></a></span><span>
</span><span id="line-2119"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077465"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077465"><span class="hs-identifier hs-var">info'</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; TcM SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier hs-var">zonkSkolemInfo</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077468"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-2120"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077464"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681077464"><span class="hs-identifier hs-var">wanted'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWCRec"><span class="hs-identifier hs-var">zonkWCRec</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681077470"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-2121"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681077475"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_skols :: [TyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077467"><span class="hs-identifier hs-var">skols'</span></a></span><span>
</span><span id="line-2122"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: [TyVar]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077466"><span class="hs-identifier hs-var">given'</span></a></span><span>
</span><span id="line-2123"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681077464"><span class="hs-identifier hs-var">wanted'</span></a></span><span>
</span><span id="line-2124"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077465"><span class="hs-identifier hs-var">info'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2125"></span><span>
</span><span id="line-2126"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkEvVar"><span class="hs-identifier hs-type">zonkEvVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span>
</span><span id="line-2127"></span><span id="zonkEvVar"><span class="annot"><span class="annottext">zonkEvVar :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkEvVar"><span class="hs-identifier hs-var hs-var">zonkEvVar</span></a></span></span><span> </span><span id="local-6989586621681077462"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077462"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; TcM Kind) -&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *).
Monad m =&gt;
(Kind -&gt; m Kind) -&gt; TyVar -&gt; m TyVar
</span><a href="GHC.Types.Var.html#updateIdTypeAndMultM"><span class="hs-identifier hs-var">updateIdTypeAndMultM</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077462"><span class="hs-identifier hs-var">var</span></a></span><span>
</span><span id="line-2128"></span><span>
</span><span id="line-2129"></span><span>
</span><span id="line-2130"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkWC"><span class="hs-identifier hs-type">zonkWC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-2131"></span><span id="zonkWC"><span class="annot"><span class="annottext">zonkWC :: WantedConstraints -&gt; TcM WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWC"><span class="hs-identifier hs-var hs-var">zonkWC</span></a></span></span><span> </span><span id="local-6989586621681077460"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681077460"><span class="hs-identifier hs-var">wc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWCRec"><span class="hs-identifier hs-var">zonkWCRec</span></a></span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681077460"><span class="hs-identifier hs-var">wc</span></a></span><span>
</span><span id="line-2132"></span><span>
</span><span id="line-2133"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkWCRec"><span class="hs-identifier hs-type">zonkWCRec</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WantedConstraints"><span class="hs-identifier hs-type">WantedConstraints</span></a></span><span>
</span><span id="line-2134"></span><span id="zonkWCRec"><span class="annot"><span class="annottext">zonkWCRec :: WantedConstraints -&gt; TcM WantedConstraints
</span><a href="GHC.Tc.Utils.TcMType.html#zonkWCRec"><span class="hs-identifier hs-var hs-var">zonkWCRec</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: WantedConstraints -&gt; Bag Ct
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077459"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077459"><span class="hs-identifier hs-var">simple</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: WantedConstraints -&gt; Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077458"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681077458"><span class="hs-identifier hs-var">implic</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_holes :: WantedConstraints -&gt; Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077456"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681077456"><span class="hs-identifier hs-var">holes</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2135"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077455"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077455"><span class="hs-identifier hs-var">simple'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bag Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Ct)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkSimples"><span class="hs-identifier hs-var">zonkSimples</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077459"><span class="hs-identifier hs-var">simple</span></a></span><span>
</span><span id="line-2136"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077454"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681077454"><span class="hs-identifier hs-var">implic'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication)
-&gt; Bag Implication
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Implication)
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Implication -&gt; IOEnv (Env TcGblEnv TcLclEnv) Implication
</span><a href="GHC.Tc.Utils.TcMType.html#zonkImplication"><span class="hs-identifier hs-var">zonkImplication</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681077458"><span class="hs-identifier hs-var">implic</span></a></span><span>
</span><span id="line-2137"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077453"><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681077453"><span class="hs-identifier hs-var">holes'</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Hole -&gt; IOEnv (Env TcGblEnv TcLclEnv) Hole)
-&gt; Bag Hole -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Hole)
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Hole -&gt; IOEnv (Env TcGblEnv TcLclEnv) Hole
</span><a href="GHC.Tc.Utils.TcMType.html#zonkHole"><span class="hs-identifier hs-var">zonkHole</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681077456"><span class="hs-identifier hs-var">holes</span></a></span><span>
</span><span id="line-2138"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WantedConstraints -&gt; TcM WantedConstraints
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WC :: Bag Ct -&gt; Bag Implication -&gt; Bag Hole -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#WC"><span class="hs-identifier hs-type">WC</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">wc_simple :: Bag Ct
</span><a href="GHC.Tc.Types.Constraint.html#wc_simple"><span class="hs-identifier hs-var">wc_simple</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077455"><span class="hs-identifier hs-var">simple'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_impl :: Bag Implication
</span><a href="GHC.Tc.Types.Constraint.html#wc_impl"><span class="hs-identifier hs-var">wc_impl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681077454"><span class="hs-identifier hs-var">implic'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">wc_holes :: Bag Hole
</span><a href="GHC.Tc.Types.Constraint.html#wc_holes"><span class="hs-identifier hs-var">wc_holes</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Hole
</span><a href="#local-6989586621681077453"><span class="hs-identifier hs-var">holes'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2139"></span><span>
</span><span id="line-2140"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkSimples"><span class="hs-identifier hs-type">zonkSimples</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Cts"><span class="hs-identifier hs-type">Cts</span></a></span><span>
</span><span id="line-2141"></span><span id="zonkSimples"><span class="annot"><span class="annottext">zonkSimples :: Bag Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Ct)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkSimples"><span class="hs-identifier hs-var hs-var">zonkSimples</span></a></span></span><span> </span><span id="local-6989586621681077450"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077450"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077449"><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077449"><span class="hs-identifier hs-var">cts'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcM Ct) -&gt; Bag Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Ct)
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Bag a -&gt; m (Bag b)
</span><a href="GHC.Data.Bag.html#mapBagM"><span class="hs-identifier hs-var">mapBagM</span></a></span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier hs-var">zonkCt</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077450"><span class="hs-identifier hs-var">cts</span></a></span><span>
</span><span id="line-2142"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zonkSimples done:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bag Ct -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077449"><span class="hs-identifier hs-var">cts'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2143"></span><span>                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bag Ct -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Bag Ct)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Ct
</span><a href="#local-6989586621681077449"><span class="hs-identifier hs-var">cts'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2144"></span><span>
</span><span id="line-2145"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkHole"><span class="hs-identifier hs-type">zonkHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span>
</span><span id="line-2146"></span><span id="zonkHole"><span class="annot"><span class="annottext">zonkHole :: Hole -&gt; IOEnv (Env TcGblEnv TcLclEnv) Hole
</span><a href="GHC.Tc.Utils.TcMType.html#zonkHole"><span class="hs-identifier hs-var hs-var">zonkHole</span></a></span></span><span> </span><span id="local-6989586621681077448"><span class="annot"><span class="annottext">hole :: Hole
</span><a href="#local-6989586621681077448"><span class="hs-identifier hs-var">hole</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Hole -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077447"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077447"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2147"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077446"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077446"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077447"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2148"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Hole -&gt; IOEnv (Env TcGblEnv TcLclEnv) Hole
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Hole
</span><a href="#local-6989586621681077448"><span class="hs-identifier hs-var">hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077446"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2149"></span><span>  </span><span class="hs-comment">-- No need to zonk the Id in any ExprHole because we never look at it</span><span>
</span><span id="line-2150"></span><span>  </span><span class="hs-comment">-- until after the final zonk and desugaring</span><span>
</span><span id="line-2151"></span><span>
</span><span id="line-2152"></span><span class="hs-comment">{- Note [zonkCt behaviour]
~~~~~~~~~~~~~~~~~~~~~~~~~~
zonkCt tries to maintain the canonical form of a Ct.  For example,
  - a CDictCan should stay a CDictCan;
  - a CIrredCan should stay a CIrredCan with its cc_status flag intact

Why?, for example:
- For CDictCan, the @GHC.Tc.Solver.expandSuperClasses@ step, which runs after the
  simple wanted and plugin loop, looks for @CDictCan@s. If a plugin is in use,
  constraints are zonked before being passed to the plugin. This means if we
  don't preserve a canonical form, @expandSuperClasses@ fails to expand
  superclasses. This is what happened in #11525.

- For CIrredCan we want to see if a constraint is insoluble with insolubleWC

On the other hand, we change CTyEqCan to CNonCanonical, because of all of
CTyEqCan's invariants, which can break during zonking. Besides, the constraint
will be canonicalised again, so there is little benefit in keeping the
CTyEqCan structure.

NB: we do not expect to see any CFunEqCans, because zonkCt is only
called on unflattened constraints.

NB: Constraints are always re-flattened etc by the canonicaliser in
@GHC.Tc.Solver.Canonical@ even if they come in as CDictCan. Only canonical constraints that
are actually in the inert set carry all the guarantees. So it is okay if zonkCt
creates e.g. a CDictCan where the cc_tyars are /not/ function free.
-}</span><span>
</span><span id="line-2180"></span><span>
</span><span id="line-2181"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier hs-type">zonkCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span>
</span><span id="line-2182"></span><span class="hs-comment">-- See Note [zonkCt behaviour]</span><span>
</span><span id="line-2183"></span><span id="zonkCt"><span class="annot"><span class="annottext">zonkCt :: Ct -&gt; TcM Ct
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier hs-var hs-var">zonkCt</span></a></span></span><span> </span><span id="local-6989586621681077445"><span class="annot"><span class="annottext">ct :: Ct
</span><a href="#local-6989586621681077445"><span class="hs-identifier hs-var">ct</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CDictCan"><span class="hs-identifier hs-type">CDictCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077442"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077442"><span class="hs-identifier hs-var">ev</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: Ct -&gt; [Kind]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077440"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077440"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2184"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077439"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077439"><span class="hs-identifier hs-var">ev'</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var">zonkCtEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077442"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-2185"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077437"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077437"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; TcM Kind) -&gt; [Kind] -&gt; TcM [Kind]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077440"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-2186"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Ct -&gt; TcM Ct) -&gt; Ct -&gt; TcM Ct
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077445"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077439"><span class="hs-identifier hs-var">ev'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cc_tyargs :: [Kind]
</span><a href="GHC.Tc.Types.Constraint.html#cc_tyargs"><span class="hs-identifier hs-var">cc_tyargs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077437"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2187"></span><span>
</span><span id="line-2188"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier hs-var">zonkCt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CTyEqCan"><span class="hs-identifier hs-type">CTyEqCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077435"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077435"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2189"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">(CtEvidence -&gt; Ct) -&gt; TcM CtEvidence -&gt; TcM Ct
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var">zonkCtEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077435"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-2190"></span><span>
</span><span id="line-2191"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier hs-var">zonkCt</span></a></span><span> </span><span id="local-6989586621681077434"><span class="annot"><span class="annottext">ct :: Ct
</span><a href="#local-6989586621681077434"><span class="hs-identifier hs-var">ct</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CIrredCan"><span class="hs-identifier hs-type">CIrredCan</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077432"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077432"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Preserve the cc_status flag</span><span>
</span><span id="line-2192"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077431"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077431"><span class="hs-identifier hs-var">ev'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var">zonkCtEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077432"><span class="hs-identifier hs-var">ev</span></a></span><span>
</span><span id="line-2193"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077434"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077431"><span class="hs-identifier hs-var">ev'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2194"></span><span>
</span><span id="line-2195"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCt"><span class="hs-identifier hs-var">zonkCt</span></a></span><span> </span><span id="local-6989586621681077430"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077430"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-2196"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isCFunEqCan</span><span> </span><span class="hs-identifier">ct</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-2197"></span><span>  </span><span class="hs-comment">-- We do not expect to see any CFunEqCans, because zonkCt is only called on</span><span>
</span><span id="line-2198"></span><span>  </span><span class="hs-comment">-- unflattened constraints.</span><span>
</span><span id="line-2199"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077428"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077428"><span class="hs-identifier hs-var">fl'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var">zonkCtEvidence</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#ctEvidence"><span class="hs-identifier hs-var">ctEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077430"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2200"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Ct -&gt; TcM Ct
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Ct
</span><a href="GHC.Tc.Types.Constraint.html#mkNonCanonical"><span class="hs-identifier hs-var">mkNonCanonical</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077428"><span class="hs-identifier hs-var">fl'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2201"></span><span>
</span><span id="line-2202"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-type">zonkCtEvidence</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-2203"></span><span id="zonkCtEvidence"><span class="annot"><span class="annottext">zonkCtEvidence :: CtEvidence -&gt; TcM CtEvidence
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var hs-var">zonkCtEvidence</span></a></span></span><span> </span><span id="local-6989586621681077427"><span class="annot"><span class="annottext">ctev :: CtEvidence
</span><a href="#local-6989586621681077427"><span class="hs-identifier hs-var">ctev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtGiven"><span class="hs-identifier hs-type">CtGiven</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: CtEvidence -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077425"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077425"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2204"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077424"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077424"><span class="hs-identifier hs-var">pred'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077425"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-2205"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077427"><span class="hs-identifier hs-var">ctev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077424"><span class="hs-identifier hs-var">pred'</span></a></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2206"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var">zonkCtEvidence</span></a></span><span> </span><span id="local-6989586621681077423"><span class="annot"><span class="annottext">ctev :: CtEvidence
</span><a href="#local-6989586621681077423"><span class="hs-identifier hs-var">ctev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtWanted"><span class="hs-identifier hs-type">CtWanted</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: CtEvidence -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077422"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077422"><span class="hs-identifier hs-var">pred</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: CtEvidence -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077421"><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681077421"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2207"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077420"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077420"><span class="hs-identifier hs-var">pred'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077422"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-2208"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077419"><span class="annot"><span class="annottext">dest' :: TcEvDest
</span><a href="#local-6989586621681077419"><span class="hs-identifier hs-var hs-var">dest'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681077421"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2209"></span><span>                       </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#EvVarDest"><span class="hs-identifier hs-type">EvVarDest</span></a></span><span> </span><span id="local-6989586621681077418"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077418"><span class="hs-identifier hs-var">ev</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#EvVarDest"><span class="hs-identifier hs-var">EvVarDest</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcEvDest) -&gt; TyVar -&gt; TcEvDest
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Kind -&gt; TyVar
</span><a href="GHC.Types.Var.html#setVarType"><span class="hs-identifier hs-var">setVarType</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077418"><span class="hs-identifier hs-var">ev</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077420"><span class="hs-identifier hs-var">pred'</span></a></span><span>
</span><span id="line-2210"></span><span>                         </span><span class="hs-comment">-- necessary in simplifyInfer</span><span>
</span><span id="line-2211"></span><span>                       </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-type">HoleDest</span></a></span><span> </span><span id="local-6989586621681077416"><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681077416"><span class="hs-identifier hs-var">h</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#HoleDest"><span class="hs-identifier hs-var">HoleDest</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681077416"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-2212"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077423"><span class="hs-identifier hs-var">ctev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077420"><span class="hs-identifier hs-var">pred'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ctev_dest :: TcEvDest
</span><a href="GHC.Tc.Types.Constraint.html#ctev_dest"><span class="hs-identifier hs-var">ctev_dest</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcEvDest
</span><a href="#local-6989586621681077419"><span class="hs-identifier hs-var">dest'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2213"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCtEvidence"><span class="hs-identifier hs-var">zonkCtEvidence</span></a></span><span> </span><span id="local-6989586621681077415"><span class="annot"><span class="annottext">ctev :: CtEvidence
</span><a href="#local-6989586621681077415"><span class="hs-identifier hs-var">ctev</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtDerived"><span class="hs-identifier hs-type">CtDerived</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: CtEvidence -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077414"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077414"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2214"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077413"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077413"><span class="hs-identifier hs-var">pred'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077414"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-2215"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; TcM CtEvidence
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077415"><span class="hs-identifier hs-var">ctev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077413"><span class="hs-identifier hs-var">pred'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2216"></span><span>
</span><span id="line-2217"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier hs-type">zonkSkolemInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span>
</span><span id="line-2218"></span><span id="zonkSkolemInfo"><span class="annot"><span class="annottext">zonkSkolemInfo :: SkolemInfo -&gt; TcM SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier hs-var hs-var">zonkSkolemInfo</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-type">SigSkol</span></a></span><span> </span><span id="local-6989586621681077411"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681077411"><span class="hs-identifier hs-var">cx</span></a></span></span><span> </span><span id="local-6989586621681077410"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077410"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681077409"><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077409"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077408"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077408"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077410"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2219"></span><span>                                            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; TcM SkolemInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; Kind -&gt; [(Name, TyVar)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-var">SigSkol</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681077411"><span class="hs-identifier hs-var">cx</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077408"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077409"><span class="hs-identifier hs-var">tv_prs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2220"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier hs-var">zonkSkolemInfo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#InferSkol"><span class="hs-identifier hs-type">InferSkol</span></a></span><span> </span><span id="local-6989586621681077406"><span class="annot"><span class="annottext">[(Name, Kind)]
</span><a href="#local-6989586621681077406"><span class="hs-identifier hs-var">ntys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077405"><span class="annot"><span class="annottext">[(Name, Kind)]
</span><a href="#local-6989586621681077405"><span class="hs-identifier hs-var">ntys'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((Name, Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Name, Kind))
-&gt; [(Name, Kind)] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [(Name, Kind)]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Name, Kind)
forall {a}. (a, Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, Kind)
</span><a href="#local-6989586621681077404"><span class="hs-identifier hs-var">do_one</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Kind)]
</span><a href="#local-6989586621681077406"><span class="hs-identifier hs-var">ntys</span></a></span><span>
</span><span id="line-2221"></span><span>                                     </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; TcM SkolemInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, Kind)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InferSkol"><span class="hs-identifier hs-var">InferSkol</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Kind)]
</span><a href="#local-6989586621681077405"><span class="hs-identifier hs-var">ntys'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2222"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2223"></span><span>    </span><span id="local-6989586621681077404"><span class="annot"><span class="annottext">do_one :: (a, Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, Kind)
</span><a href="#local-6989586621681077404"><span class="hs-identifier hs-var hs-var">do_one</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077401"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681077401"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077400"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077400"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077399"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077399"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077400"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, Kind) -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681077401"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077399"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2224"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier hs-var">zonkSkolemInfo</span></a></span><span> </span><span id="local-6989586621681077398"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077398"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; TcM SkolemInfo
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077398"><span class="hs-identifier hs-var">skol_info</span></a></span><span>
</span><span id="line-2225"></span><span>
</span><span id="line-2226"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
\subsection{Zonking -- the main work-horses: zonkTcType, zonkTcTyVar}
*                                                                      *
*              For internal use only!                                  *
*                                                                      *
************************************************************************

-}</span><span>
</span><span id="line-2236"></span><span>
</span><span id="line-2237"></span><span class="hs-comment">-- For unbound, mutable tyvars, zonkType uses the function given to it</span><span>
</span><span id="line-2238"></span><span class="hs-comment">-- For tyvars bound at a for-all, zonkType zonks them to an immutable</span><span>
</span><span id="line-2239"></span><span class="hs-comment">--      type variable and zonks the kind too</span><span>
</span><span id="line-2240"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-type">zonkTcType</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-2241"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypes"><span class="hs-identifier hs-type">zonkTcTypes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2242"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCo"><span class="hs-identifier hs-type">zonkCo</span></a></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-2243"></span><span>
</span><span id="line-2244"></span><span class="hs-special">(</span><span id="zonkTcType"><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span></span><span class="hs-special">,</span><span> </span><span id="zonkTcTypes"><span class="annot"><span class="annottext">[Kind] -&gt; TcM [Kind]
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypes"><span class="hs-identifier hs-var">zonkTcTypes</span></a></span></span><span class="hs-special">,</span><span> </span><span id="zonkCo"><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCo"><span class="hs-identifier hs-var">zonkCo</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Coercion] -&gt; TcM [Coercion]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-2245"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoMapper () (IOEnv (Env TcGblEnv TcLclEnv))
-&gt; (Kind -&gt; TcM Kind, [Kind] -&gt; TcM [Kind],
    Coercion -&gt; TcM Coercion, [Coercion] -&gt; TcM [Coercion])
forall (m :: * -&gt; *).
Monad m =&gt;
TyCoMapper () m
-&gt; (Kind -&gt; m Kind, [Kind] -&gt; m [Kind], Coercion -&gt; m Coercion,
    [Coercion] -&gt; m [Coercion])
</span><a href="GHC.Core.Type.html#mapTyCo"><span class="hs-identifier hs-var">mapTyCo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoMapper () (IOEnv (Env TcGblEnv TcLclEnv))
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypeMapper"><span class="hs-identifier hs-var">zonkTcTypeMapper</span></a></span><span>
</span><span id="line-2246"></span><span>
</span><span id="line-2247"></span><span class="hs-comment">-- | A suitable TyCoMapper for zonking a type during type-checking,</span><span>
</span><span id="line-2248"></span><span class="hs-comment">-- before all metavars are filled in.</span><span>
</span><span id="line-2249"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypeMapper"><span class="hs-identifier hs-type">zonkTcTypeMapper</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Type.html#TyCoMapper"><span class="hs-identifier hs-type">TyCoMapper</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span>
</span><span id="line-2250"></span><span id="zonkTcTypeMapper"><span class="annot"><span class="annottext">zonkTcTypeMapper :: TyCoMapper () (IOEnv (Env TcGblEnv TcLclEnv))
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTypeMapper"><span class="hs-identifier hs-var hs-var">zonkTcTypeMapper</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCoMapper :: forall env (m :: * -&gt; *).
(env -&gt; TyVar -&gt; m Kind)
-&gt; (env -&gt; TyVar -&gt; m Coercion)
-&gt; (env -&gt; CoercionHole -&gt; m Coercion)
-&gt; (env -&gt; TyVar -&gt; ArgFlag -&gt; m (env, TyVar))
-&gt; (TyCon -&gt; m TyCon)
-&gt; TyCoMapper env m
</span><a href="GHC.Core.Type.html#TyCoMapper"><span class="hs-identifier hs-type">TyCoMapper</span></a></span><span>
</span><span id="line-2251"></span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcm_tyvar :: () -&gt; TyVar -&gt; TcM Kind
</span><a href="GHC.Core.Type.html#tcm_tyvar"><span class="hs-identifier hs-var">tcm_tyvar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcM Kind) -&gt; () -&gt; TyVar -&gt; TcM Kind
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-var">zonkTcTyVar</span></a></span><span>
</span><span id="line-2252"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcm_covar :: () -&gt; TyVar -&gt; TcM Coercion
</span><a href="GHC.Core.Type.html#tcm_covar"><span class="hs-identifier hs-var">tcm_covar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TcM Coercion) -&gt; () -&gt; TyVar -&gt; TcM Coercion
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681077390"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077390"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkCoVarCo"><span class="hs-identifier hs-var">mkCoVarCo</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; Coercion)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar -&gt; TcM Coercion
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077390"><span class="hs-identifier hs-var">cv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2253"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcm_hole :: () -&gt; CoercionHole -&gt; TcM Coercion
</span><a href="GHC.Core.Type.html#tcm_hole"><span class="hs-identifier hs-var">tcm_hole</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; CoercionHole -&gt; TcM Coercion
</span><a href="#local-6989586621681077388"><span class="hs-identifier hs-var">hole</span></a></span><span>
</span><span id="line-2254"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcm_tycobinder :: () -&gt; TyVar -&gt; ArgFlag -&gt; IOEnv (Env TcGblEnv TcLclEnv) ((), TyVar)
</span><a href="GHC.Core.Type.html#tcm_tycobinder"><span class="hs-identifier hs-var">tcm_tycobinder</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681077386"><span class="annot"><span class="annottext">()
</span><a href="#local-6989586621681077386"><span class="hs-identifier hs-var">_env</span></a></span></span><span> </span><span id="local-6989586621681077385"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077385"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681077384"><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621681077384"><span class="hs-identifier hs-var">_vis</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; ((), TyVar))
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
-&gt; IOEnv (Env TcGblEnv TcLclEnv) ((), TyVar)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077385"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2255"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcm_tycon :: TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyCon
</span><a href="GHC.Core.Type.html#tcm_tycon"><span class="hs-identifier hs-var">tcm_tycon</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyCon
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyCon"><span class="hs-identifier hs-var">zonkTcTyCon</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2256"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2257"></span><span>    </span><span class="annot"><a href="#local-6989586621681077388"><span class="hs-identifier hs-type">hole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>
</span><span id="line-2258"></span><span>    </span><span id="local-6989586621681077388"><span class="annot"><span class="annottext">hole :: () -&gt; CoercionHole -&gt; TcM Coercion
</span><a href="#local-6989586621681077388"><span class="hs-identifier hs-var hs-var">hole</span></a></span></span><span> </span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681077381"><span class="annot"><span class="annottext">hole :: CoercionHole
</span><a href="#local-6989586621681077381"><span class="hs-identifier hs-var">hole</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#CoercionHole"><span class="hs-identifier hs-type">CoercionHole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_ref :: CoercionHole -&gt; IORef (Maybe Coercion)
</span><a href="GHC.Core.TyCo.Rep.html#ch_ref"><span class="hs-identifier hs-var">ch_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077380"><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681077380"><span class="hs-identifier hs-var">ref</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ch_co_var :: CoercionHole -&gt; TyVar
</span><a href="GHC.Core.TyCo.Rep.html#ch_co_var"><span class="hs-identifier hs-var">ch_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077379"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077379"><span class="hs-identifier hs-var">cv</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2259"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077378"><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="#local-6989586621681077378"><span class="hs-identifier hs-var">contents</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Maybe Coercion)
forall a gbl lcl. TcRef a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#readTcRef"><span class="hs-identifier hs-var">readTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef (Maybe Coercion)
</span><a href="#local-6989586621681077380"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-2260"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="#local-6989586621681077378"><span class="hs-identifier hs-var">contents</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2261"></span><span>               </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681077377"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077377"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077376"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077376"><span class="hs-identifier hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCo"><span class="hs-identifier hs-var">zonkCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077377"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-2262"></span><span>                             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Coercion -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#checkCoercionHole"><span class="hs-identifier hs-var">checkCoercionHole</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077379"><span class="hs-identifier hs-var">cv</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681077376"><span class="hs-identifier hs-var">co'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2263"></span><span>               </span><span class="annot"><span class="annottext">Maybe Coercion
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077375"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077375"><span class="hs-identifier hs-var">cv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCoVar"><span class="hs-identifier hs-var">zonkCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077379"><span class="hs-identifier hs-var">cv</span></a></span><span>
</span><span id="line-2264"></span><span>                             </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Coercion
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Coercion) -&gt; Coercion -&gt; TcM Coercion
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionHole -&gt; Coercion
</span><a href="GHC.Core.TyCo.Rep.html#HoleCo"><span class="hs-identifier hs-var">HoleCo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionHole
</span><a href="#local-6989586621681077381"><span class="hs-identifier hs-var">hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ch_co_var :: TyVar
</span><a href="GHC.Core.TyCo.Rep.html#ch_co_var"><span class="hs-identifier hs-var">ch_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077375"><span class="hs-identifier hs-var">cv'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2265"></span><span>
</span><span id="line-2266"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyCon"><span class="hs-identifier hs-type">zonkTcTyCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCon"><span class="hs-identifier hs-type">TcTyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcTyCon"><span class="hs-identifier hs-type">TcTyCon</span></a></span><span>
</span><span id="line-2267"></span><span class="hs-comment">-- Only called on TcTyCons</span><span>
</span><span id="line-2268"></span><span class="hs-comment">-- A non-poly TcTyCon may have unification</span><span>
</span><span id="line-2269"></span><span class="hs-comment">-- variables that need zonking, but poly ones cannot</span><span>
</span><span id="line-2270"></span><span id="zonkTcTyCon"><span class="annot"><span class="annottext">zonkTcTyCon :: TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyCon
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyCon"><span class="hs-identifier hs-var hs-var">zonkTcTyCon</span></a></span></span><span> </span><span id="local-6989586621681077373"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681077373"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-2271"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#tcTyConIsPoly"><span class="hs-identifier hs-var hs-var">tcTyConIsPoly</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681077373"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681077373"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-2272"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077371"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077371"><span class="hs-identifier hs-var">tck'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Kind
</span><a href="GHC.Core.TyCon.html#tyConKind"><span class="hs-identifier hs-var hs-var">tyConKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681077373"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2273"></span><span>                         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyCon
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Kind -&gt; TyCon
</span><a href="GHC.Core.TyCon.html#setTcTyConKind"><span class="hs-identifier hs-var">setTcTyConKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681077373"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077371"><span class="hs-identifier hs-var">tck'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2274"></span><span>
</span><span id="line-2275"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-type">zonkTcTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>
</span><span id="line-2276"></span><span class="hs-comment">-- Simply look through all Flexis</span><span>
</span><span id="line-2277"></span><span id="zonkTcTyVar"><span class="annot"><span class="annottext">zonkTcTyVar :: TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-var hs-var">zonkTcTyVar</span></a></span></span><span> </span><span id="local-6989586621681077368"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077368"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-2278"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; Bool
</span><a href="GHC.Types.Var.html#isTcTyVar"><span class="hs-identifier hs-var">isTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077368"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2279"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcTyVarDetails
</span><a href="GHC.Types.Var.html#tcTyVarDetails"><span class="hs-identifier hs-var">tcTyVarDetails</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077368"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2280"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-type">SkolemTv</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="#local-6989586621681077367"><span class="hs-identifier hs-var">zonk_kind_and_return</span></a></span><span>
</span><span id="line-2281"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#RuntimeUnk"><span class="hs-identifier hs-type">RuntimeUnk</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="#local-6989586621681077367"><span class="hs-identifier hs-var">zonk_kind_and_return</span></a></span><span>
</span><span id="line-2282"></span><span>      </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#MetaTv"><span class="hs-identifier hs-type">MetaTv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mtv_ref :: TcTyVarDetails -&gt; IORef MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#mtv_ref"><span class="hs-identifier hs-var">mtv_ref</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077365"><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077365"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2283"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077364"><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077364"><span class="hs-identifier hs-var">cts</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; TcM MetaDetails
forall a env. IORef a -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#readMutVar"><span class="hs-identifier hs-var">readMutVar</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077365"><span class="hs-identifier hs-var">ref</span></a></span><span>
</span><span id="line-2284"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="#local-6989586621681077364"><span class="hs-identifier hs-var">cts</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2285"></span><span>                    </span><span class="annot"><span class="annottext">MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Flexi"><span class="hs-identifier hs-var">Flexi</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="#local-6989586621681077367"><span class="hs-identifier hs-var">zonk_kind_and_return</span></a></span><span>
</span><span id="line-2286"></span><span>                    </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-type">Indirect</span></a></span><span> </span><span id="local-6989586621681077363"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077363"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077362"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077362"><span class="hs-identifier hs-var">zty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077363"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2287"></span><span>                                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails -&gt; MetaDetails -&gt; TcRn ()
forall a gbl lcl. TcRef a -&gt; a -&gt; TcRnIf gbl lcl ()
</span><a href="GHC.Tc.Utils.Monad.html#writeTcRef"><span class="hs-identifier hs-var">writeTcRef</span></a></span><span> </span><span class="annot"><span class="annottext">IORef MetaDetails
</span><a href="#local-6989586621681077365"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; MetaDetails
</span><a href="GHC.Tc.Utils.TcType.html#Indirect"><span class="hs-identifier hs-var">Indirect</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077362"><span class="hs-identifier hs-var">zty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2288"></span><span>                                        </span><span class="hs-comment">-- See Note [Sharing in zonking]</span><span>
</span><span id="line-2289"></span><span>                                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077362"><span class="hs-identifier hs-var">zty</span></a></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2290"></span><span>
</span><span id="line-2291"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-comment">-- coercion variable</span><span>
</span><span id="line-2292"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM Kind
</span><a href="#local-6989586621681077367"><span class="hs-identifier hs-var">zonk_kind_and_return</span></a></span><span>
</span><span id="line-2293"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2294"></span><span>    </span><span id="local-6989586621681077367"><span class="annot"><span class="annottext">zonk_kind_and_return :: TcM Kind
</span><a href="#local-6989586621681077367"><span class="hs-identifier hs-var hs-var">zonk_kind_and_return</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077359"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077359"><span class="hs-identifier hs-var">z_tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTyCoVarKind"><span class="hs-identifier hs-var">zonkTyCoVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077368"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2295"></span><span>                              </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077359"><span class="hs-identifier hs-var">z_tv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2296"></span><span>
</span><span id="line-2297"></span><span class="hs-comment">-- Variant that assumes that any result of zonking is still a TyVar.</span><span>
</span><span id="line-2298"></span><span class="hs-comment">-- Should be used only on skolems and TyVarTvs</span><span>
</span><span id="line-2299"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-type">zonkTcTyVarToTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#HasDebugCallStack"><span class="hs-identifier hs-type">HasDebugCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>
</span><span id="line-2300"></span><span id="zonkTcTyVarToTyVar"><span class="annot"><span class="annottext">zonkTcTyVarToTyVar :: HasDebugCallStack =&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-var hs-var">zonkTcTyVarToTyVar</span></a></span></span><span> </span><span id="local-6989586621681077355"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077355"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-2301"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077354"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077354"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVar"><span class="hs-identifier hs-var">zonkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077355"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2302"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077349"><span class="annot"><span class="annottext">tv' :: TyVar
</span><a href="#local-6989586621681077349"><span class="hs-identifier hs-var hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Maybe TyVar
</span><a href="GHC.Tc.Utils.TcType.html#tcGetTyVar_maybe"><span class="hs-identifier hs-var">tcGetTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077354"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2303"></span><span>                     </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681077347"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077347"><span class="hs-identifier hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077347"><span class="hs-identifier hs-var">tv'</span></a></span><span>
</span><span id="line-2304"></span><span>                     </span><span class="annot"><span class="annottext">Maybe TyVar
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TyVar
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;zonkTcTyVarToTyVar&quot;</span></span><span>
</span><span id="line-2305"></span><span>                                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077355"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077354"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2306"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077349"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2307"></span><span>
</span><span id="line-2308"></span><span id="local-6989586621681077346"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkInvisTVBinder"><span class="hs-identifier hs-type">zonkInvisTVBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#VarBndr"><span class="hs-identifier hs-type">VarBndr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681077346"><span class="hs-identifier hs-type">spec</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#VarBndr"><span class="hs-identifier hs-type">VarBndr</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681077346"><span class="hs-identifier hs-type">spec</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-2309"></span><span id="zonkInvisTVBinder"><span class="annot"><span class="annottext">zonkInvisTVBinder :: forall fl. VarBndr TyVar fl -&gt; TcM (VarBndr TyVar fl)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkInvisTVBinder"><span class="hs-identifier hs-var hs-var">zonkInvisTVBinder</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681077342"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077342"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681077341"><span class="annot"><span class="annottext">spec
</span><a href="#local-6989586621681077341"><span class="hs-identifier hs-var">spec</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077340"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077340"><span class="hs-identifier hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-var">zonkTcTyVarToTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077342"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2310"></span><span>                                      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">VarBndr TyVar spec -&gt; TcM (VarBndr TyVar spec)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; spec -&gt; VarBndr TyVar spec
forall var argf. var -&gt; argf -&gt; VarBndr var argf
</span><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-var">Bndr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077340"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="annot"><span class="annottext">spec
</span><a href="#local-6989586621681077341"><span class="hs-identifier hs-var">spec</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2311"></span><span>
</span><span id="line-2312"></span><span class="hs-comment">-- zonkId is used *during* typechecking just to zonk the Id's type</span><span>
</span><span id="line-2313"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkId"><span class="hs-identifier hs-type">zonkId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span>
</span><span id="line-2314"></span><span id="zonkId"><span class="annot"><span class="annottext">zonkId :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkId"><span class="hs-identifier hs-var hs-var">zonkId</span></a></span></span><span> </span><span id="local-6989586621681077338"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077338"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; TcM Kind) -&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
forall (m :: * -&gt; *).
Monad m =&gt;
(Kind -&gt; m Kind) -&gt; TyVar -&gt; m TyVar
</span><a href="GHC.Types.Var.html#updateIdTypeAndMultM"><span class="hs-identifier hs-var">Id.updateIdTypeAndMultM</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077338"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-2315"></span><span>
</span><span id="line-2316"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkCoVar"><span class="hs-identifier hs-type">zonkCoVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span>
</span><span id="line-2317"></span><span id="zonkCoVar"><span class="annot"><span class="annottext">zonkCoVar :: TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkCoVar"><span class="hs-identifier hs-var hs-var">zonkCoVar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkId"><span class="hs-identifier hs-var">zonkId</span></a></span><span>
</span><span id="line-2318"></span><span>
</span><span id="line-2319"></span><span class="hs-comment">{- Note [Sharing in zonking]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have
   alpha :-&gt; beta :-&gt; gamma :-&gt; ty
where the &quot;:-&gt;&quot; means that the unification variable has been
filled in with Indirect. Then when zonking alpha, it'd be nice
to short-circuit beta too, so we end up with
   alpha :-&gt; zty
   beta  :-&gt; zty
   gamma :-&gt; zty
where zty is the zonked version of ty.  That way, if we come across
beta later, we'll have less work to do.  (And indeed the same for
alpha.)

This is easily achieved: just overwrite (Indirect ty) with (Indirect
zty).  Non-systematic perf comparisons suggest that this is a modest
win.

But c.f Note [Sharing when zonking to Type] in GHC.Tc.Utils.Zonk.

%************************************************************************
%*                                                                      *
                 Tidying
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-2345"></span><span>
</span><span id="line-2346"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-type">zonkTidyTcType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2347"></span><span id="zonkTidyTcType"><span class="annot"><span class="annottext">zonkTidyTcType :: TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var hs-var">zonkTidyTcType</span></a></span></span><span> </span><span id="local-6989586621681077337"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077337"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077336"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077336"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077335"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077335"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077336"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2348"></span><span>                           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, Kind) -&gt; TcM (TidyEnv, Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; (TidyEnv, Kind)
</span><a href="GHC.Core.TyCo.Tidy.html#tidyOpenType"><span class="hs-identifier hs-var">tidyOpenType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077337"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077335"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2349"></span><span>
</span><span id="line-2350"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcTypes"><span class="hs-identifier hs-type">zonkTidyTcTypes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2351"></span><span id="zonkTidyTcTypes"><span class="annot"><span class="annottext">zonkTidyTcTypes :: TidyEnv -&gt; [Kind] -&gt; TcM (TidyEnv, [Kind])
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcTypes"><span class="hs-identifier hs-var hs-var">zonkTidyTcTypes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Kind] -&gt; TidyEnv -&gt; [Kind] -&gt; TcM (TidyEnv, [Kind])
</span><a href="#local-6989586621681077333"><span class="hs-identifier hs-var">zonkTidyTcTypes'</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-2352"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681077333"><span class="annot"><span class="annottext">zonkTidyTcTypes' :: [Kind] -&gt; TidyEnv -&gt; [Kind] -&gt; TcM (TidyEnv, [Kind])
</span><a href="#local-6989586621681077333"><span class="hs-identifier hs-var hs-var">zonkTidyTcTypes'</span></a></span></span><span> </span><span id="local-6989586621681077330"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077330"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span id="local-6989586621681077329"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077329"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, [Kind]) -&gt; TcM (TidyEnv, [Kind])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077329"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Kind] -&gt; [Kind]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077330"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2353"></span><span>        </span><span class="annot"><a href="#local-6989586621681077333"><span class="hs-identifier hs-var">zonkTidyTcTypes'</span></a></span><span> </span><span id="local-6989586621681077327"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077327"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span id="local-6989586621681077326"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077326"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077325"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077325"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681077324"><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077324"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2354"></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077323"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077323"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077322"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077322"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077326"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077325"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2355"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Kind] -&gt; TidyEnv -&gt; [Kind] -&gt; TcM (TidyEnv, [Kind])
</span><a href="#local-6989586621681077333"><span class="hs-identifier hs-var">zonkTidyTcTypes'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077322"><span class="hs-identifier hs-var">ty'</span></a></span><span class="annot"><span class="annottext">Kind -&gt; [Kind] -&gt; [Kind]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077327"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077323"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[Kind]
</span><a href="#local-6989586621681077324"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2356"></span><span>
</span><span id="line-2357"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-type">zonkTidyOrigin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2358"></span><span id="zonkTidyOrigin"><span class="annot"><span class="annottext">zonkTidyOrigin :: TidyEnv -&gt; CtOrigin -&gt; TcM (TidyEnv, CtOrigin)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var hs-var">zonkTidyOrigin</span></a></span></span><span> </span><span id="local-6989586621681077321"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077321"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#GivenOrigin"><span class="hs-identifier hs-type">GivenOrigin</span></a></span><span> </span><span id="local-6989586621681077319"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077319"><span class="hs-identifier hs-var">skol_info</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2359"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077318"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077318"><span class="hs-identifier hs-var">skol_info1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; TcM SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#zonkSkolemInfo"><span class="hs-identifier hs-var">zonkSkolemInfo</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077319"><span class="hs-identifier hs-var">skol_info</span></a></span><span>
</span><span id="line-2360"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077317"><span class="annot"><span class="annottext">skol_info2 :: SkolemInfo
</span><a href="#local-6989586621681077317"><span class="hs-identifier hs-var hs-var">skol_info2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; SkolemInfo -&gt; SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-var">tidySkolemInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077321"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077318"><span class="hs-identifier hs-var">skol_info1</span></a></span><span>
</span><span id="line-2361"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CtOrigin) -&gt; TcM (TidyEnv, CtOrigin)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077321"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SkolemInfo -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#GivenOrigin"><span class="hs-identifier hs-var">GivenOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077317"><span class="hs-identifier hs-var">skol_info2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2362"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span id="local-6989586621681077316"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077316"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077315"><span class="annot"><span class="annottext">orig :: CtOrigin
</span><a href="#local-6989586621681077315"><span class="hs-identifier hs-var">orig</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#TypeEqOrigin"><span class="hs-identifier hs-type">TypeEqOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: CtOrigin -&gt; Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077314"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077314"><span class="hs-identifier hs-var">act</span></a></span></span><span>
</span><span id="line-2363"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: CtOrigin -&gt; Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077313"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077313"><span class="hs-identifier hs-var">exp</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2364"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077312"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077312"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077311"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077311"><span class="hs-identifier hs-var">act'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077316"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077314"><span class="hs-identifier hs-var">act</span></a></span><span>
</span><span id="line-2365"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077310"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077310"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077309"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077309"><span class="hs-identifier hs-var">exp'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077312"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077313"><span class="hs-identifier hs-var">exp</span></a></span><span>
</span><span id="line-2366"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CtOrigin) -&gt; TcM (TidyEnv, CtOrigin)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077310"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077315"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uo_actual :: Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_actual"><span class="hs-identifier hs-var">uo_actual</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077311"><span class="hs-identifier hs-var">act'</span></a></span><span>
</span><span id="line-2367"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uo_expected :: Kind
</span><a href="GHC.Tc.Types.Origin.html#uo_expected"><span class="hs-identifier hs-var">uo_expected</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077309"><span class="hs-identifier hs-var">exp'</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2368"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span id="local-6989586621681077308"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077308"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#KindEqOrigin"><span class="hs-identifier hs-type">KindEqOrigin</span></a></span><span> </span><span id="local-6989586621681077306"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077306"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681077305"><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681077305"><span class="hs-identifier hs-var">m_ty2</span></a></span></span><span> </span><span id="local-6989586621681077304"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077304"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681077303"><span class="annot"><span class="annottext">Maybe TypeOrKind
</span><a href="#local-6989586621681077303"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2369"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077302"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077302"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077301"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077301"><span class="hs-identifier hs-var">ty1'</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077308"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077306"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-2370"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077300"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077300"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077299"><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681077299"><span class="hs-identifier hs-var">m_ty2'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681077305"><span class="hs-identifier hs-var">m_ty2</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-2371"></span><span>                             </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681077298"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077298"><span class="hs-identifier hs-var">ty2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; Maybe Kind) -&gt; (TidyEnv, Kind) -&gt; (TidyEnv, Maybe Kind)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (d, b) (d, c)
</span><a href="../../base/src/Control.Arrow.html#second"><span class="hs-identifier hs-var">second</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">((TidyEnv, Kind) -&gt; (TidyEnv, Maybe Kind))
-&gt; TcM (TidyEnv, Kind)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TidyEnv, Maybe Kind)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077302"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077298"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-2372"></span><span>                             </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, Maybe Kind)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TidyEnv, Maybe Kind)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077302"><span class="hs-identifier hs-var">env1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Kind
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2373"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077297"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077297"><span class="hs-identifier hs-var">env3</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077296"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077296"><span class="hs-identifier hs-var">orig'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; CtOrigin -&gt; TcM (TidyEnv, CtOrigin)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077300"><span class="hs-identifier hs-var">env2</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077304"><span class="hs-identifier hs-var">orig</span></a></span><span>
</span><span id="line-2374"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CtOrigin) -&gt; TcM (TidyEnv, CtOrigin)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077297"><span class="hs-identifier hs-var">env3</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Maybe Kind -&gt; CtOrigin -&gt; Maybe TypeOrKind -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#KindEqOrigin"><span class="hs-identifier hs-var">KindEqOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077301"><span class="hs-identifier hs-var">ty1'</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Kind
</span><a href="#local-6989586621681077299"><span class="hs-identifier hs-var">m_ty2'</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077296"><span class="hs-identifier hs-var">orig'</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe TypeOrKind
</span><a href="#local-6989586621681077303"><span class="hs-identifier hs-var">t_or_k</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2375"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span id="local-6989586621681077295"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077295"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#FunDepOrigin1"><span class="hs-identifier hs-type">FunDepOrigin1</span></a></span><span> </span><span id="local-6989586621681077293"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077293"><span class="hs-identifier hs-var">p1</span></a></span></span><span> </span><span id="local-6989586621681077292"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077292"><span class="hs-identifier hs-var">o1</span></a></span></span><span> </span><span id="local-6989586621681077291"><span class="annot"><span class="annottext">RealSrcSpan
</span><a href="#local-6989586621681077291"><span class="hs-identifier hs-var">l1</span></a></span></span><span> </span><span id="local-6989586621681077290"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077290"><span class="hs-identifier hs-var">p2</span></a></span></span><span> </span><span id="local-6989586621681077289"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077289"><span class="hs-identifier hs-var">o2</span></a></span></span><span> </span><span id="local-6989586621681077288"><span class="annot"><span class="annottext">RealSrcSpan
</span><a href="#local-6989586621681077288"><span class="hs-identifier hs-var">l2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2376"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077287"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077287"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077286"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077286"><span class="hs-identifier hs-var">p1'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077295"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077293"><span class="hs-identifier hs-var">p1</span></a></span><span>
</span><span id="line-2377"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077285"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077285"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077284"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077284"><span class="hs-identifier hs-var">p2'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077287"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077290"><span class="hs-identifier hs-var">p2</span></a></span><span>
</span><span id="line-2378"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CtOrigin) -&gt; TcM (TidyEnv, CtOrigin)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077285"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind
-&gt; CtOrigin
-&gt; RealSrcSpan
-&gt; Kind
-&gt; CtOrigin
-&gt; RealSrcSpan
-&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#FunDepOrigin1"><span class="hs-identifier hs-var">FunDepOrigin1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077286"><span class="hs-identifier hs-var">p1'</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077292"><span class="hs-identifier hs-var">o1</span></a></span><span> </span><span class="annot"><span class="annottext">RealSrcSpan
</span><a href="#local-6989586621681077291"><span class="hs-identifier hs-var">l1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077284"><span class="hs-identifier hs-var">p2'</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077289"><span class="hs-identifier hs-var">o2</span></a></span><span> </span><span class="annot"><span class="annottext">RealSrcSpan
</span><a href="#local-6989586621681077288"><span class="hs-identifier hs-var">l2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2379"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span id="local-6989586621681077283"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077283"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#FunDepOrigin2"><span class="hs-identifier hs-type">FunDepOrigin2</span></a></span><span> </span><span id="local-6989586621681077281"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077281"><span class="hs-identifier hs-var">p1</span></a></span></span><span> </span><span id="local-6989586621681077280"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077280"><span class="hs-identifier hs-var">o1</span></a></span></span><span> </span><span id="local-6989586621681077279"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077279"><span class="hs-identifier hs-var">p2</span></a></span></span><span> </span><span id="local-6989586621681077278"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681077278"><span class="hs-identifier hs-var">l2</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2380"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077277"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077277"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077276"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077276"><span class="hs-identifier hs-var">p1'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077283"><span class="hs-identifier hs-var">env</span></a></span><span>  </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077281"><span class="hs-identifier hs-var">p1</span></a></span><span>
</span><span id="line-2381"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077275"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077275"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077274"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077274"><span class="hs-identifier hs-var">p2'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; TcM (TidyEnv, Kind)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077277"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077279"><span class="hs-identifier hs-var">p2</span></a></span><span>
</span><span id="line-2382"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681077273"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077273"><span class="hs-identifier hs-var">env3</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077272"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077272"><span class="hs-identifier hs-var">o1'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; CtOrigin -&gt; TcM (TidyEnv, CtOrigin)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077275"><span class="hs-identifier hs-var">env2</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077280"><span class="hs-identifier hs-var">o1</span></a></span><span>
</span><span id="line-2383"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CtOrigin) -&gt; TcM (TidyEnv, CtOrigin)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077273"><span class="hs-identifier hs-var">env3</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; CtOrigin -&gt; Kind -&gt; SrcSpan -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#FunDepOrigin2"><span class="hs-identifier hs-var">FunDepOrigin2</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077276"><span class="hs-identifier hs-var">p1'</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077272"><span class="hs-identifier hs-var">o1'</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077274"><span class="hs-identifier hs-var">p2'</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681077278"><span class="hs-identifier hs-var">l2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2384"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#zonkTidyOrigin"><span class="hs-identifier hs-var">zonkTidyOrigin</span></a></span><span> </span><span id="local-6989586621681077271"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077271"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077270"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077270"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CtOrigin) -&gt; TcM (TidyEnv, CtOrigin)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077271"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681077270"><span class="hs-identifier hs-var">orig</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2385"></span><span>
</span><span id="line-2386"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-2387"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidyCt"><span class="hs-identifier hs-type">tidyCt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Ct"><span class="hs-identifier hs-type">Ct</span></a></span><span>
</span><span id="line-2388"></span><span class="hs-comment">-- Used only in error reporting</span><span>
</span><span id="line-2389"></span><span id="tidyCt"><span class="annot"><span class="annottext">tidyCt :: TidyEnv -&gt; Ct -&gt; Ct
</span><a href="GHC.Tc.Utils.TcMType.html#tidyCt"><span class="hs-identifier hs-var hs-var">tidyCt</span></a></span></span><span> </span><span id="local-6989586621681077269"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077269"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077268"><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077268"><span class="hs-identifier hs-var">ct</span></a></span></span><span>
</span><span id="line-2390"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077268"><span class="hs-identifier hs-var">ct</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cc_ev :: CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#cc_ev"><span class="hs-identifier hs-var">cc_ev</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence -&gt; CtEvidence
</span><a href="#local-6989586621681077267"><span class="hs-identifier hs-var">tidy_ev</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ct -&gt; CtEvidence
</span><a href="GHC.Tc.Types.Constraint.html#ctEvidence"><span class="hs-identifier hs-var">ctEvidence</span></a></span><span> </span><span class="annot"><span class="annottext">Ct
</span><a href="#local-6989586621681077268"><span class="hs-identifier hs-var">ct</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2391"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2392"></span><span>    </span><span class="annot"><a href="#local-6989586621681077267"><span class="hs-identifier hs-type">tidy_ev</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#CtEvidence"><span class="hs-identifier hs-type">CtEvidence</span></a></span><span>
</span><span id="line-2393"></span><span>     </span><span class="hs-comment">-- NB: we do not tidy the ctev_evar field because we don't</span><span>
</span><span id="line-2394"></span><span>     </span><span class="hs-comment">--     show it in error messages</span><span>
</span><span id="line-2395"></span><span>    </span><span id="local-6989586621681077267"><span class="annot"><span class="annottext">tidy_ev :: CtEvidence -&gt; CtEvidence
</span><a href="#local-6989586621681077267"><span class="hs-identifier hs-var hs-var">tidy_ev</span></a></span></span><span> </span><span id="local-6989586621681077266"><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077266"><span class="hs-identifier hs-var">ctev</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077266"><span class="hs-identifier hs-var">ctev</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ctev_pred :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var">ctev_pred</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077269"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtEvidence -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#ctev_pred"><span class="hs-identifier hs-var hs-var">ctev_pred</span></a></span><span> </span><span class="annot"><span class="annottext">CtEvidence
</span><a href="#local-6989586621681077266"><span class="hs-identifier hs-var">ctev</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2396"></span><span>
</span><span id="line-2397"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidyHole"><span class="hs-identifier hs-type">tidyHole</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span>
</span><span id="line-2398"></span><span id="tidyHole"><span class="annot"><span class="annottext">tidyHole :: TidyEnv -&gt; Hole -&gt; Hole
</span><a href="GHC.Tc.Utils.TcMType.html#tidyHole"><span class="hs-identifier hs-var hs-var">tidyHole</span></a></span></span><span> </span><span id="local-6989586621681077264"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077264"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077263"><span class="annot"><span class="annottext">h :: Hole
</span><a href="#local-6989586621681077263"><span class="hs-identifier hs-var">h</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Hole"><span class="hs-identifier hs-type">Hole</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Hole -&gt; Kind
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681077262"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077262"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Hole
</span><a href="#local-6989586621681077263"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hole_ty :: Kind
</span><a href="GHC.Tc.Types.Constraint.html#hole_ty"><span class="hs-identifier hs-var">hole_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077264"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077262"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2399"></span><span>
</span><span id="line-2400"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-2401"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidyEvVar"><span class="hs-identifier hs-type">tidyEvVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span>
</span><span id="line-2402"></span><span id="tidyEvVar"><span class="annot"><span class="annottext">tidyEvVar :: TidyEnv -&gt; TyVar -&gt; TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#tidyEvVar"><span class="hs-identifier hs-var hs-var">tidyEvVar</span></a></span></span><span> </span><span id="local-6989586621681077261"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077261"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077260"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077260"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Kind -&gt; Kind) -&gt; TyVar -&gt; TyVar
</span><a href="GHC.Types.Var.html#updateIdTypeAndMult"><span class="hs-identifier hs-var">updateIdTypeAndMult</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077261"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077260"><span class="hs-identifier hs-var">var</span></a></span><span>
</span><span id="line-2403"></span><span>
</span><span id="line-2404"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-2405"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-type">tidySkolemInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span>
</span><span id="line-2406"></span><span id="tidySkolemInfo"><span class="annot"><span class="annottext">tidySkolemInfo :: TidyEnv -&gt; SkolemInfo -&gt; SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-var hs-var">tidySkolemInfo</span></a></span></span><span> </span><span id="local-6989586621681077258"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077258"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#DerivSkol"><span class="hs-identifier hs-type">DerivSkol</span></a></span><span> </span><span id="local-6989586621681077256"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077256"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#DerivSkol"><span class="hs-identifier hs-var">DerivSkol</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077258"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077256"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2407"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-var">tidySkolemInfo</span></a></span><span> </span><span id="local-6989586621681077255"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077255"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-type">SigSkol</span></a></span><span> </span><span id="local-6989586621681077254"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681077254"><span class="hs-identifier hs-var">cx</span></a></span></span><span> </span><span id="local-6989586621681077253"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077253"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681077252"><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077252"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; UserTypeCtxt -&gt; Kind -&gt; [(Name, TyVar)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#tidySigSkol"><span class="hs-identifier hs-var">tidySigSkol</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077255"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681077254"><span class="hs-identifier hs-var">cx</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077253"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077252"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>
</span><span id="line-2408"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-var">tidySkolemInfo</span></a></span><span> </span><span id="local-6989586621681077250"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077250"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#InferSkol"><span class="hs-identifier hs-type">InferSkol</span></a></span><span> </span><span id="local-6989586621681077249"><span class="annot"><span class="annottext">[(Name, Kind)]
</span><a href="#local-6989586621681077249"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Kind)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InferSkol"><span class="hs-identifier hs-var">InferSkol</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Kind -&gt; Kind) -&gt; [(Name, Kind)] -&gt; [(Name, Kind)]
forall b c a. (b -&gt; c) -&gt; [(a, b)] -&gt; [(a, c)]
</span><a href="GHC.Utils.Misc.html#mapSnd"><span class="hs-identifier hs-var">mapSnd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077250"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, Kind)]
</span><a href="#local-6989586621681077249"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2409"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-var">tidySkolemInfo</span></a></span><span> </span><span id="local-6989586621681077247"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077247"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UnifyForAllSkol"><span class="hs-identifier hs-type">UnifyForAllSkol</span></a></span><span> </span><span id="local-6989586621681077245"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077245"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#UnifyForAllSkol"><span class="hs-identifier hs-var">UnifyForAllSkol</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077247"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077245"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2410"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySkolemInfo"><span class="hs-identifier hs-var">tidySkolemInfo</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span id="local-6989586621681077244"><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077244"><span class="hs-identifier hs-var">info</span></a></span></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="#local-6989586621681077244"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-2411"></span><span>
</span><span id="line-2412"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#tidySigSkol"><span class="hs-identifier hs-type">tidySigSkol</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#UserTypeCtxt"><span class="hs-identifier hs-type">UserTypeCtxt</span></a></span><span>
</span><span id="line-2413"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#SkolemInfo"><span class="hs-identifier hs-type">SkolemInfo</span></a></span><span>
</span><span id="line-2414"></span><span class="hs-comment">-- We need to take special care when tidying SigSkol</span><span>
</span><span id="line-2415"></span><span class="hs-comment">-- See Note [SigSkol SkolemInfo] in &quot;GHC.Tc.Types.Origin&quot;</span><span>
</span><span id="line-2416"></span><span id="tidySigSkol"><span class="annot"><span class="annottext">tidySigSkol :: TidyEnv -&gt; UserTypeCtxt -&gt; Kind -&gt; [(Name, TyVar)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Utils.TcMType.html#tidySigSkol"><span class="hs-identifier hs-var hs-var">tidySigSkol</span></a></span></span><span> </span><span id="local-6989586621681077243"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077243"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077242"><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681077242"><span class="hs-identifier hs-var">cx</span></a></span></span><span> </span><span id="local-6989586621681077241"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077241"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681077240"><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077240"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span>
</span><span id="line-2417"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; Kind -&gt; [(Name, TyVar)] -&gt; SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#SigSkol"><span class="hs-identifier hs-var">SigSkol</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681077242"><span class="hs-identifier hs-var">cx</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="#local-6989586621681077239"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077243"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077241"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077238"><span class="hs-identifier hs-var">tv_prs'</span></a></span><span>
</span><span id="line-2418"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2419"></span><span>    </span><span id="local-6989586621681077238"><span class="annot"><span class="annottext">tv_prs' :: [(Name, TyVar)]
</span><a href="#local-6989586621681077238"><span class="hs-identifier hs-var hs-var">tv_prs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TyVar) -&gt; [(Name, TyVar)] -&gt; [(Name, TyVar)]
forall b c a. (b -&gt; c) -&gt; [(a, b)] -&gt; [(a, c)]
</span><a href="GHC.Utils.Misc.html#mapSnd"><span class="hs-identifier hs-var">mapSnd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; TyVar -&gt; TyVar
</span><a href="GHC.Core.TyCo.Tidy.html#tidyTyCoVarOcc"><span class="hs-identifier hs-var">tidyTyCoVarOcc</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077243"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077240"><span class="hs-identifier hs-var">tv_prs</span></a></span><span>
</span><span id="line-2420"></span><span>    </span><span id="local-6989586621681077236"><span class="annot"><span class="annottext">inst_env :: NameEnv TyVar
</span><a href="#local-6989586621681077236"><span class="hs-identifier hs-var hs-var">inst_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, TyVar)] -&gt; NameEnv TyVar
forall a. [(Name, a)] -&gt; NameEnv a
</span><a href="GHC.Types.Name.Env.html#mkNameEnv"><span class="hs-identifier hs-var">mkNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, TyVar)]
</span><a href="#local-6989586621681077238"><span class="hs-identifier hs-var">tv_prs'</span></a></span><span>
</span><span id="line-2421"></span><span>
</span><span id="line-2422"></span><span>    </span><span id="local-6989586621681077239"><span class="annot"><span class="annottext">tidy_ty :: TidyEnv -&gt; Kind -&gt; Kind
</span><a href="#local-6989586621681077239"><span class="hs-identifier hs-var hs-var">tidy_ty</span></a></span></span><span> </span><span id="local-6989586621681077234"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077234"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-type">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681077233"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077233"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681077232"><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621681077232"><span class="hs-identifier hs-var">vis</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077231"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077231"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2423"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarBndr TyVar ArgFlag -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Rep.html#ForAllTy"><span class="hs-identifier hs-var">ForAllTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; ArgFlag -&gt; VarBndr TyVar ArgFlag
forall var argf. var -&gt; argf -&gt; VarBndr var argf
</span><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-var">Bndr</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077230"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="#local-6989586621681077232"><span class="hs-identifier hs-var">vis</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="#local-6989586621681077239"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077229"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077231"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2424"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-2425"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621681077229"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077229"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077230"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077230"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TyVar -&gt; (TidyEnv, TyVar)
</span><a href="#local-6989586621681077228"><span class="hs-identifier hs-var">tidy_tv_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077234"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077233"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2426"></span><span>
</span><span id="line-2427"></span><span>    </span><span class="annot"><a href="#local-6989586621681077239"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span> </span><span id="local-6989586621681077227"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077227"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077226"><span class="annot"><span class="annottext">ty :: Kind
</span><a href="#local-6989586621681077226"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#FunTy"><span class="hs-identifier hs-type">FunTy</span></a></span><span> </span><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="GHC.Types.Var.html#InvisArg"><span class="hs-identifier hs-var">InvisArg</span></a></span><span> </span><span id="local-6989586621681077224"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077224"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621681077223"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077223"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span id="local-6989586621681077222"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077222"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Look under  c =&gt; t</span><span>
</span><span id="line-2428"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077226"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_mult :: Kind
</span><a href="GHC.Core.TyCo.Rep.html#ft_mult"><span class="hs-identifier hs-var">ft_mult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="#local-6989586621681077239"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077227"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077224"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2429"></span><span>             </span><span class="annot"><span class="annottext">ft_arg :: Kind
</span><a href="GHC.Core.TyCo.Rep.html#ft_arg"><span class="hs-identifier hs-var">ft_arg</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077227"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077223"><span class="hs-identifier hs-var">arg</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-2430"></span><span>             </span><span class="annot"><span class="annottext">ft_res :: Kind
</span><a href="GHC.Core.TyCo.Rep.html#ft_res"><span class="hs-identifier hs-var">ft_res</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="#local-6989586621681077239"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077227"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077222"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2431"></span><span>
</span><span id="line-2432"></span><span>    </span><span class="annot"><a href="#local-6989586621681077239"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span> </span><span id="local-6989586621681077218"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077218"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681077217"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077217"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077218"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077217"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2433"></span><span>
</span><span id="line-2434"></span><span>    </span><span class="annot"><a href="#local-6989586621681077228"><span class="hs-identifier hs-type">tidy_tv_bndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2435"></span><span>    </span><span id="local-6989586621681077228"><span class="annot"><span class="annottext">tidy_tv_bndr :: TidyEnv -&gt; TyVar -&gt; (TidyEnv, TyVar)
</span><a href="#local-6989586621681077228"><span class="hs-identifier hs-var hs-var">tidy_tv_bndr</span></a></span></span><span> </span><span id="local-6989586621681077216"><span class="annot"><span class="annottext">env :: TidyEnv
</span><a href="#local-6989586621681077216"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681077215"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681077215"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077214"><span class="annot"><span class="annottext">VarEnv TyVar
</span><a href="#local-6989586621681077214"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681077213"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077213"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-2436"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681077212"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077212"><span class="hs-identifier hs-var">tv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">NameEnv TyVar -&gt; Name -&gt; Maybe TyVar
forall a. NameEnv a -&gt; Name -&gt; Maybe a
</span><a href="GHC.Types.Name.Env.html#lookupNameEnv"><span class="hs-identifier hs-var">lookupNameEnv</span></a></span><span> </span><span class="annot"><span class="annottext">NameEnv TyVar
</span><a href="#local-6989586621681077236"><span class="hs-identifier hs-var">inst_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077213"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2437"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681077215"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv TyVar -&gt; TyVar -&gt; TyVar -&gt; VarEnv TyVar
forall a. VarEnv a -&gt; TyVar -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv TyVar
</span><a href="#local-6989586621681077214"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077213"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077212"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077212"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2438"></span><span>
</span><span id="line-2439"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2440"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; TyVar -&gt; (TidyEnv, TyVar)
</span><a href="GHC.Core.TyCo.Tidy.html#tidyVarBndr"><span class="hs-identifier hs-var">tidyVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077216"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077213"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-2441"></span><span>
</span><span id="line-2442"></span><span class="hs-comment">-------------------------------------------------------------------------</span><span>
</span><span id="line-2443"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
             Levity polymorphism checks
*                                                                       *
*************************************************************************

See Note [Levity polymorphism checking] in GHC.HsToCore.Monad

-}</span><span>
</span><span id="line-2453"></span><span>
</span><span id="line-2454"></span><span class="hs-comment">-- | According to the rules around representation polymorphism</span><span>
</span><span id="line-2455"></span><span class="hs-comment">-- (see https://gitlab.haskell.org/ghc/ghc/wikis/no-sub-kinds), no binder</span><span>
</span><span id="line-2456"></span><span class="hs-comment">-- can have a representation-polymorphic type. This check ensures</span><span>
</span><span id="line-2457"></span><span class="hs-comment">-- that we respect this rule. It is a bit regrettable that this error</span><span>
</span><span id="line-2458"></span><span class="hs-comment">-- occurs in zonking, after which we should have reported all errors.</span><span>
</span><span id="line-2459"></span><span class="hs-comment">-- But it's hard to see where else to do it, because this can be discovered</span><span>
</span><span id="line-2460"></span><span class="hs-comment">-- only after all solving is done. And, perhaps most importantly, this</span><span>
</span><span id="line-2461"></span><span class="hs-comment">-- isn't really a compositional property of a type system, so it's</span><span>
</span><span id="line-2462"></span><span class="hs-comment">-- not a terrible surprise that the check has to go in an awkward spot.</span><span>
</span><span id="line-2463"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#ensureNotLevPoly"><span class="hs-identifier hs-type">ensureNotLevPoly</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>  </span><span class="hs-comment">-- its zonked type</span><span>
</span><span id="line-2464"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>  </span><span class="hs-comment">-- where this happened</span><span>
</span><span id="line-2465"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2466"></span><span id="ensureNotLevPoly"><span class="annot"><span class="annottext">ensureNotLevPoly :: Kind -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#ensureNotLevPoly"><span class="hs-identifier hs-var hs-var">ensureNotLevPoly</span></a></span></span><span> </span><span id="local-6989586621681077208"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077208"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681077207"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681077207"><span class="hs-identifier hs-var">doc</span></a></span></span><span>
</span><span id="line-2467"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcRn () -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#whenNoErrs"><span class="hs-identifier hs-var">whenNoErrs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>   </span><span class="hs-comment">-- sometimes we end up zonking bogus definitions of type</span><span>
</span><span id="line-2468"></span><span>                   </span><span class="hs-comment">-- forall a. a. See, for example, test ghci/scripts/T9140</span><span>
</span><span id="line-2469"></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#checkForLevPoly"><span class="hs-identifier hs-var">checkForLevPoly</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681077207"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077208"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2470"></span><span>
</span><span id="line-2471"></span><span>  </span><span class="hs-comment">-- See Note [Levity polymorphism checking] in GHC.HsToCore.Monad</span><span>
</span><span id="line-2472"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkForLevPoly"><span class="hs-identifier hs-type">checkForLevPoly</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2473"></span><span id="checkForLevPoly"><span class="annot"><span class="annottext">checkForLevPoly :: SDoc -&gt; Kind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.TcMType.html#checkForLevPoly"><span class="hs-identifier hs-var hs-var">checkForLevPoly</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; Kind -&gt; TcRn ()
forall (m :: * -&gt; *).
Monad m =&gt;
(SDoc -&gt; m ()) -&gt; SDoc -&gt; Kind -&gt; m ()
</span><a href="GHC.Tc.Utils.TcMType.html#checkForLevPolyX"><span class="hs-identifier hs-var">checkForLevPolyX</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span>
</span><span id="line-2474"></span><span>
</span><span id="line-2475"></span><span id="local-6989586621681078898"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#checkForLevPolyX"><span class="hs-identifier hs-type">checkForLevPolyX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681078898"><span class="hs-identifier hs-type">m</span></a></span><span>
</span><span id="line-2476"></span><span>                 </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681078898"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- how to report an error</span><span>
</span><span id="line-2477"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621681078898"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-2478"></span><span id="checkForLevPolyX"><span class="annot"><span class="annottext">checkForLevPolyX :: forall (m :: * -&gt; *).
Monad m =&gt;
(SDoc -&gt; m ()) -&gt; SDoc -&gt; Kind -&gt; m ()
</span><a href="GHC.Tc.Utils.TcMType.html#checkForLevPolyX"><span class="hs-identifier hs-var hs-var">checkForLevPolyX</span></a></span></span><span> </span><span id="local-6989586621681077203"><span class="annot"><span class="annottext">SDoc -&gt; m ()
</span><a href="#local-6989586621681077203"><span class="hs-identifier hs-var">add_err</span></a></span></span><span> </span><span id="local-6989586621681077202"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681077202"><span class="hs-identifier hs-var">extra</span></a></span></span><span> </span><span id="local-6989586621681077201"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077201"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-2479"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; Bool
</span><a href="GHC.Core.Type.html#isTypeLevPoly"><span class="hs-identifier hs-var">isTypeLevPoly</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077201"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2480"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; m ()
</span><a href="#local-6989586621681077203"><span class="hs-identifier hs-var">add_err</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; SDoc
</span><a href="GHC.Tc.Utils.TcMType.html#formatLevPolyErr"><span class="hs-identifier hs-var">formatLevPolyErr</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077201"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681077202"><span class="hs-identifier hs-var">extra</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2481"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-2482"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; m ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2483"></span><span>
</span><span id="line-2484"></span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#formatLevPolyErr"><span class="hs-identifier hs-type">formatLevPolyErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>  </span><span class="hs-comment">-- levity-polymorphic type</span><span>
</span><span id="line-2485"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2486"></span><span id="formatLevPolyErr"><span class="annot"><span class="annottext">formatLevPolyErr :: Kind -&gt; SDoc
</span><a href="GHC.Tc.Utils.TcMType.html#formatLevPolyErr"><span class="hs-identifier hs-var hs-var">formatLevPolyErr</span></a></span></span><span> </span><span id="local-6989586621681077199"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077199"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-2487"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;A levity-polymorphic type is not allowed here:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-2488"></span><span>       </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Type:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprWithTYPE"><span class="hs-identifier hs-var">pprWithTYPE</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077197"><span class="hs-identifier hs-var">tidy_ty</span></a></span><span>
</span><span id="line-2489"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Kind:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Kind -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprWithTYPE"><span class="hs-identifier hs-var">pprWithTYPE</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077196"><span class="hs-identifier hs-var">tidy_ki</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-2490"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2491"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681077195"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077195"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681077197"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077197"><span class="hs-identifier hs-var">tidy_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; (TidyEnv, Kind)
</span><a href="GHC.Core.TyCo.Tidy.html#tidyOpenType"><span class="hs-identifier hs-var">tidyOpenType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="GHC.Types.Var.Env.html#emptyTidyEnv"><span class="hs-identifier hs-var">emptyTidyEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077199"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-2492"></span><span>    </span><span id="local-6989586621681077196"><span class="annot"><span class="annottext">tidy_ki :: Kind
</span><a href="#local-6989586621681077196"><span class="hs-identifier hs-var hs-var">tidy_ki</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077195"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Kind -&gt; Kind
Kind -&gt; Kind
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077199"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2493"></span><span>
</span><span id="line-2494"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
             Error messages
*                                                                       *
*************************************************************************

-}</span><span>
</span><span id="line-2502"></span><span>
</span><span id="line-2503"></span><span class="hs-comment">-- See Note [Naughty quantification candidates]</span><span>
</span><span id="line-2504"></span><span id="local-6989586621681078949"><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#naughtyQuantification"><span class="hs-identifier hs-type">naughtyQuantification</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>   </span><span class="hs-comment">-- original type user wanted to quantify</span><span>
</span><span id="line-2505"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span>  </span><span class="hs-comment">-- naughty var</span><span>
</span><span id="line-2506"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#TyVarSet"><span class="hs-identifier hs-type">TyVarSet</span></a></span><span> </span><span class="hs-comment">-- skolems that would escape</span><span>
</span><span id="line-2507"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681078949"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-2508"></span><span id="naughtyQuantification"><span class="annot"><span class="annottext">naughtyQuantification :: forall a. Kind -&gt; TyVar -&gt; TcTyVarSet -&gt; TcM a
</span><a href="GHC.Tc.Utils.TcMType.html#naughtyQuantification"><span class="hs-identifier hs-var hs-var">naughtyQuantification</span></a></span></span><span> </span><span id="local-6989586621681077188"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077188"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span> </span><span id="local-6989586621681077187"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077187"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681077186"><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077186"><span class="hs-identifier hs-var">escapees</span></a></span></span><span>
</span><span id="line-2509"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681077185"><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077185"><span class="hs-identifier hs-var">orig_ty1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; TcM Kind
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcType"><span class="hs-identifier hs-var">zonkTcType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077188"><span class="hs-identifier hs-var">orig_ty</span></a></span><span>  </span><span class="hs-comment">-- in case it's not zonked</span><span>
</span><span id="line-2510"></span><span>
</span><span id="line-2511"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681077184"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077184"><span class="hs-identifier hs-var">escapees'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar)
-&gt; [TyVar] -&gt; TcM [TyVar]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
TyVar -&gt; IOEnv (Env TcGblEnv TcLclEnv) TyVar
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTcTyVarToTyVar"><span class="hs-identifier hs-var">zonkTcTyVarToTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">([TyVar] -&gt; TcM [TyVar]) -&gt; [TyVar] -&gt; TcM [TyVar]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2512"></span><span>                      </span><span class="annot"><span class="annottext">TcTyVarSet -&gt; [TyVar]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarSet
</span><a href="#local-6989586621681077186"><span class="hs-identifier hs-var">escapees</span></a></span><span>
</span><span id="line-2513"></span><span>                     </span><span class="hs-comment">-- we'll just be printing, so no harmful non-determinism</span><span>
</span><span id="line-2514"></span><span>
</span><span id="line-2515"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681077183"><span class="annot"><span class="annottext">fvs :: [TyVar]
</span><a href="#local-6989586621681077183"><span class="hs-identifier hs-var hs-var">fvs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Kind -&gt; [TyVar]
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfTypeWellScoped"><span class="hs-identifier hs-var">tyCoVarsOfTypeWellScoped</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077185"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span>
</span><span id="line-2516"></span><span>             </span><span id="local-6989586621681077181"><span class="annot"><span class="annottext">env0 :: TidyEnv
</span><a href="#local-6989586621681077181"><span class="hs-identifier hs-var hs-var">env0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TyVar] -&gt; TidyEnv
</span><a href="GHC.Core.TyCo.Tidy.html#tidyFreeTyCoVars"><span class="hs-identifier hs-var">tidyFreeTyCoVars</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="GHC.Types.Var.Env.html#emptyTidyEnv"><span class="hs-identifier hs-var">emptyTidyEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077183"><span class="hs-identifier hs-var">fvs</span></a></span><span>
</span><span id="line-2517"></span><span>             </span><span id="local-6989586621681077179"><span class="annot"><span class="annottext">env :: TidyEnv
</span><a href="#local-6989586621681077179"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077181"><span class="hs-identifier hs-var">env0</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [TyVar] -&gt; TidyEnv
</span><a href="GHC.Types.Var.Env.html#delTidyEnvList"><span class="hs-operator hs-var">`delTidyEnvList`</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077184"><span class="hs-identifier hs-var">escapees'</span></a></span><span>
</span><span id="line-2518"></span><span>                    </span><span class="hs-comment">-- this avoids gratuitous renaming of the escaped</span><span>
</span><span id="line-2519"></span><span>                    </span><span class="hs-comment">-- variables; very confusing to users!</span><span>
</span><span id="line-2520"></span><span>
</span><span id="line-2521"></span><span>             </span><span id="local-6989586621681077177"><span class="annot"><span class="annottext">orig_ty' :: Kind
</span><a href="#local-6989586621681077177"><span class="hs-identifier hs-var hs-var">orig_ty'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Kind -&gt; Kind
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077179"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077185"><span class="hs-identifier hs-var">orig_ty1</span></a></span><span>
</span><span id="line-2522"></span><span>             </span><span id="local-6989586621681077176"><span class="annot"><span class="annottext">ppr_tidied :: [TyVar] -&gt; SDoc
</span><a href="#local-6989586621681077176"><span class="hs-identifier hs-var hs-var">ppr_tidied</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTyVars"><span class="hs-identifier hs-var">pprTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">([TyVar] -&gt; SDoc) -&gt; ([TyVar] -&gt; [TyVar]) -&gt; [TyVar] -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(TyVar -&gt; TyVar) -&gt; [TyVar] -&gt; [TyVar]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; TyVar -&gt; TyVar
</span><a href="GHC.Core.TyCo.Tidy.html#tidyTyCoVarOcc"><span class="hs-identifier hs-var">tidyTyCoVarOcc</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077179"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2523"></span><span>             </span><span id="local-6989586621681077175"><span class="annot"><span class="annottext">doc :: SDoc
</span><a href="#local-6989586621681077175"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprWithExplicitKindsWhen"><span class="hs-identifier hs-var">pprWithExplicitKindsWhen</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2524"></span><span>                   </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cannot generalise type; skolem&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
forall a. [a] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#plural"><span class="hs-identifier hs-var">plural</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077184"><span class="hs-identifier hs-var">escapees'</span></a></span><span>
</span><span id="line-2525"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="#local-6989586621681077176"><span class="hs-identifier hs-var">ppr_tidied</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077184"><span class="hs-identifier hs-var">escapees'</span></a></span><span>
</span><span id="line-2526"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;would escape&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
forall a. [a] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#itsOrTheir"><span class="hs-identifier hs-var">itsOrTheir</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681077184"><span class="hs-identifier hs-var">escapees'</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;scope&quot;</span></span><span>
</span><span id="line-2527"></span><span>                              </span><span class="hs-special">]</span><span>
</span><span id="line-2528"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;if I tried to quantify&quot;</span></span><span>
</span><span id="line-2529"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
</span><a href="#local-6989586621681077176"><span class="hs-identifier hs-var">ppr_tidied</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681077187"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-2530"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;in this type:&quot;</span></span><span>
</span><span id="line-2531"></span><span>                              </span><span class="hs-special">]</span><span>
</span><span id="line-2532"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Kind -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTidiedType"><span class="hs-identifier hs-var">pprTidiedType</span></a></span><span> </span><span class="annot"><span class="annottext">Kind
</span><a href="#local-6989586621681077177"><span class="hs-identifier hs-var">orig_ty'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2533"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(Indeed, I sometimes struggle even printing this correctly,&quot;</span></span><span>
</span><span id="line-2534"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; due to its ill-scoped nature.)&quot;</span></span><span>
</span><span id="line-2535"></span><span>                        </span><span class="hs-special">]</span><span>
</span><span id="line-2536"></span><span>
</span><span id="line-2537"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM a
forall a. (TidyEnv, SDoc) -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#failWithTcM"><span class="hs-identifier hs-var">failWithTcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681077179"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681077175"><span class="hs-identifier hs-var">doc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2538"></span></pre></body></html>